pdqr module
All distributions are parameterized by the mean, standard deviation (sigma), skew and shape parameters. For the Generalized Hyperbolic distribution, there is an additional parameter lamda, representing a real parameter in the Generalized Inverse Gaussian (GIG) distribution of the Normal mean variance mixture representation of the distribution. For each distribution (*), there is a function for the cumulative distribution (p*), density (d*), quantile (q*) and random sampling (r*). Additional functions for calculating the skewness and kurtosis given the skew and shape parameters are also available.
Normal distribution
The Normal Distribution is a spherical distribution described completely by it first two moments, the mean and variance. Formally, the random variable \(x\) is said to be normally distributed with mean \(\mu\) and variance \(\sigma^2\) (both of which may be time varying), with density given by,
where \(\mu \in \mathbb{R}\) and \(\sigma \in \mathbb R_{> 0}\).
- pdqr.dnorm(x: ArrayLike, mu: ArrayLike = 0, sigma: ArrayLike = 1, log: bool = False) NDArray[float64][source]
(Normal) Probability Density Function (dnorm)
In cases when the parameters are vectors of size n (>1), then they must be equal in size to x (unless they are of size 1 in which case they are recycled). This is achieved using the numpy vectorize function.
- Parameters:
x – a vector of quantiles
mu – the mean
sigma – the standard deviation
log – whether to return the log density
- Return type:
a numpy array
- pdqr.pnorm(q: ArrayLike, mu: ArrayLike = 0, sigma: ArrayLike = 1, lower_tail: bool = True) NDArray[float64][source]
(Normal) Cumulative Probability Function (pnorm)
In cases when the parameters are vectors of size n (>1), then they must be equal in size to q (unless they are of size 1 in which case they are recycled). This is achieved using the numpy vectorize function.
- Parameters:
q – a vector of quantiles
mu – the mean
sigma – the standard deviation
lower_tail – if TRUE (default), probabilities are P[X ≤ x] otherwise, P[X > x]
- Return type:
a numpy array
- pdqr.qnorm(p: ArrayLike, mu: ArrayLike = 0, sigma: ArrayLike = 1, lower_tail: bool = True) NDArray[float64][source]
(Normal) Quantile Function (qnorm)
In cases when the parameters are vectors of size n (>1), then they must be equal in size to p (unless they are of size 1 in which case they are recycled). This is achieved using the numpy vectorize function.
- Parameters:
p – a vector of probabilities
mu – the mean
sigma – the standard deviation
lower_tail – if TRUE (default), probabilities are P[X ≤ x] otherwise, P[X > x]
- Return type:
a numpy array
- pdqr.rnorm(n: int = 1, mu: float = 0, sigma: float = 1, seed: int | None = None) NDArray[float64][source]
(Normal) Random Number Function (rnorm)
- Parameters:
n – the number of draws
mu – the mean
sigma – the standard deviation
seed – an optional value to initialize the random seed generator
- Return type:
a numpy array
Student’s T distribution
The Student’s t distribution is described completely by a shape parameter \(\nu\), but for standardization we proceed by using its 3 parameter representation as follows:
where \(\alpha\), \(\beta\), and \(\nu\) are the location, scale and shape parameters respectively, and \(\Gamma\) is the Gamma function. Similar to the GED distribution described later, this is a unimodal and symmetric distribution where the location parameter \(\alpha\) is the mean (and mode) of the distribution while the variance is:
For the purposes of standardization we require that:
Substituting \(\frac{(\nu- 2)}{\nu }\) we obtain the standardized Student’s distribution:
The Student distribution has zero skewness and excess kurtosis equal to \(6/(\nu - 4)\) for \(\nu > 4\).
- pdqr.dstd(x: ArrayLike, mu: ArrayLike = 0, sigma: ArrayLike = 1, shape: ArrayLike = 5, log: bool = False) NDArray[float64][source]
(Student) Probability Density Function (dstd)
In cases when the parameters are vectors of size n (>1), then they must be equal in size to x (unless they are of size 1 in which case they are recycled). This is achieved using the numpy vectorize function.
- Parameters:
x – a vector of quantiles
mu – the mean
sigma – the standard deviation
shape – the shape parameter (degrees of freedom)
log – whether to return the log density
- Return type:
a numpy array
- pdqr.pstd(q: ArrayLike, mu: ArrayLike = 0, sigma: ArrayLike = 1, shape: ArrayLike = 5, lower_tail: bool = True) NDArray[float64][source]
(Student) Cumulative Probability Function (pstd)
In cases when the parameters are vectors of size n (>1), then they must be equal in size to q (unless they are of size 1 in which case they are recycled). This is achieved using the numpy vectorize function.
- Parameters:
q – a vector of quantiles
mu – the mean
sigma – the standard deviation
shape – the shape parameter (degrees of freedom)
lower_tail – if TRUE (default), probabilities are P[X ≤ x] otherwise, P[X > x]
- Return type:
a numpy array
- pdqr.qstd(p: ArrayLike, mu: ArrayLike = 0, sigma: ArrayLike = 1, shape: ArrayLike = 5, lower_tail: bool = True) NDArray[float64][source]
(Student) Quantile Function (qstd)
In cases when the parameters are vectors of size n (>1), then they must be equal in size to p (unless they are of size 1 in which case they are recycled). This is achieved using the numpy vectorize function.
- Parameters:
p – a vector of probabilities
mu – the mean
sigma – the standard deviation
shape – the shape parameter (degrees of freedom)
lower_tail – if TRUE (default), probabilities are P[X ≤ x] otherwise, P[X > x]
- Return type:
a numpy array
- pdqr.rstd(n: int = 1, mu: float = 0, sigma: float = 1, shape: float = 5, seed: int | None = None) NDArray[float64][source]
(Student) Random Number Function (rstd)
- Parameters:
n – the number of draws
mu – the mean
sigma – the standard deviation
shape – the shape parameter (degrees of freedom)
seed – an optional value to initialize the random seed generator
- Return type:
a numpy array
Generalized Error distribution
The Generalized Error Distribution is a 3 parameter distribution belonging to the exponential family with conditional density given by,
with \(\alpha\), \(\beta\) and \(\kappa\) representing the location, scale and shape parameters. Since the distribution is symmetric and unimodal the location parameter is also the mode, median and mean of the distribution (i.e. \(\mu\)). By symmetry, all odd moments beyond the mean are zero. The variance and kurtosis are given by,
As \(\kappa\) decreases the density gets flatter and flatter while in the limit as \(\kappa \to \infty\), the distribution tends towards the uniform. Special cases are the Normal when \(\kappa=2\), the Laplace when \(\kappa=1\). Standardization is simple and involves re-scaling the density to have unit standard deviation:
Finally, substituting into the scaled density of \(z\):
- pdqr.dged(x: ArrayLike, mu: ArrayLike = 0, sigma: ArrayLike = 1, shape: ArrayLike = 5, log: bool = False) NDArray[float64][source]
(GED) Probability Density Function (dged)
In cases when the parameters are vectors of size n (>1), then they must be equal in size to x (unless they are of size 1 in which case they are recycled). This is achieved using the numpy vectorize function.
- Parameters:
x – a vector of quantiles
mu – the mean
sigma – the standard deviation
shape – the shape parameter
log – whether to return the log density
- Return type:
a numpy array
- pdqr.pged(q: ArrayLike, mu: ArrayLike = 0, sigma: ArrayLike = 1, shape: ArrayLike = 5, lower_tail: bool = True) NDArray[float64][source]
(GED) Cumulative Probability Function (pged)
In cases when the parameters are vectors of size n (>1), then they must be equal in size to q (unless they are of size 1 in which case they are recycled). This is achieved using the numpy vectorize function.
- Parameters:
q – a vector of quantiles
mu – the mean
sigma – the standard deviation
shape – the shape parameter
lower_tail – if TRUE (default), probabilities are P[X ≤ x] otherwise, P[X > x]
- Return type:
a numpy array
- pdqr.qged(p: ArrayLike, mu: ArrayLike = 0, sigma: ArrayLike = 1, shape: ArrayLike = 5, lower_tail: bool = True) NDArray[float64][source]
(GED) Quantile Function (qged)
In cases when the parameters are vectors of size n (>1), then they must be equal in size to p (unless they are of size 1 in which case they are recycled). This is achieved using the numpy vectorize function.
- Parameters:
p – a vector of probabilities
mu – the mean
sigma – the standard deviation
shape – the shape parameter (degrees of freedom)
lower_tail – if TRUE (default), probabilities are P[X ≤ x] otherwise, P[X > x]
- Return type:
a numpy array
- pdqr.rged(n: int = 1, mu: float = 0, sigma: float = 1, shape: float = 5, seed: int | None = None) NDArray[float64][source]
(GED) Random Number Function (rged)
- Parameters:
n – the number of draws
mu – the mean
sigma – the standard deviation
shape – the shape parameter (degrees of freedom)
seed – an optional value to initialize the random seed generator
- Return type:
a numpy array
Skewed Distributions by Inverse Scale Factors
[Fernandez and Steel, 1998] proposed introducing skewness into unimodal and symmetric distributions by introducing inverse scale factors in the positive and negative real half lines.
Given a skew parameter, \(\xi\) (when \(\xi=1\), the distribution is symmetric), the density of a random variable z can be represented as:
where \(\xi \in {\mathbb{R}^ + }\) and \(H(.)\) is the Heaviside function. The absolute moments, required for deriving the central moments, are generated from the following function:
The mean and variance are then defined as:
The Normal, Student and GED distributions have skew variants which have been standardized to zero mean, unit variance by making use of the moment conditions given above.
Skew Normal distribution
- pdqr.dsnorm(x: ArrayLike, mu: ArrayLike = 0, sigma: ArrayLike = 1, skew: ArrayLike = 2, log: bool = False) NDArray[float64][source]
(Skew-Normal) Probability Density Function (dsnorm)
In cases when the parameters are vectors of size n (>1), then they must be equal in size to x (unless they are of size 1 in which case they are recycled). This is achieved using the numpy vectorize function.
- Parameters:
x – a vector of quantiles
mu – the mean
sigma – the standard deviation
skew – the skew parameter
log – whether to return the log density
- Return type:
a numpy array
- pdqr.psnorm(q: ArrayLike, mu: ArrayLike = 0, sigma: ArrayLike = 1, skew: ArrayLike = 2, lower_tail: bool = True) NDArray[float64][source]
(Skew-Normal) Cumulative Probability Function (psnorm)
In cases when the parameters are vectors of size n (>1), then they must be equal in size to q (unless they are of size 1 in which case they are recycled). This is achieved using the numpy vectorize function.
- Parameters:
q – a vector of quantiles
mu – the mean
sigma – the standard deviation
skew – the skew parameter
lower_tail – if TRUE (default), probabilities are P[X ≤ x] otherwise, P[X > x]
- Return type:
a numpy array
- pdqr.qsnorm(p: ArrayLike, mu: ArrayLike = 0, sigma: ArrayLike = 1, skew: ArrayLike = 2, lower_tail: bool = True) NDArray[float64][source]
(Skew-Normal) Quantile Function (qsnorm)
In cases when the parameters are vectors of size n (>1), then they must be equal in size to p (unless they are of size 1 in which case they are recycled). This is achieved using the numpy vectorize function.
- Parameters:
p – a vector of probabilities
mu – the mean
sigma – the standard deviation
skew – the skew parameter
lower_tail – if TRUE (default), probabilities are P[X ≤ x] otherwise, P[X > x]
- Return type:
a numpy array
- pdqr.rsnorm(n: int = 1, mu: float = 0, sigma: float = 1, skew: float = 2, seed: int | None = None) NDArray[float64][source]
(Skew-Normal) Random Number Function (rsnorm)
- Parameters:
n – the number of draws
mu – the mean
sigma – the standard deviation
skew – the skew parameter
seed – an optional value to initialize the random seed generator
- Return type:
a numpy array
Skew Generalized Error distribution
- pdqr.dsged(x: ArrayLike, mu: ArrayLike = 0, sigma: ArrayLike = 1, skew: ArrayLike = 2, shape: ArrayLike = 4, log: bool = False) NDArray[float64][source]
(Skew-GED) Probability Density Function (dsged)
In cases when the parameters are vectors of size n (>1), then they must be equal in size to x (unless they are of size 1 in which case they are recycled). This is achieved using the numpy vectorize function.
- Parameters:
x – a vector of quantiles
mu – the mean
sigma – the standard deviation
skew – the skew parameter
shape – the shape parameter
log – whether to return the log density
- Return type:
a numpy array
- pdqr.psged(q: ArrayLike, mu: ArrayLike = 0, sigma: ArrayLike = 1, skew: ArrayLike = 2, shape: ArrayLike = 4, lower_tail: bool = True) NDArray[float64][source]
(Skew-GED) Cumulative Probability Function (psged)
In cases when the parameters are vectors of size n (>1), then they must be equal in size to q (unless they are of size 1 in which case they are recycled). This is achieved using the numpy vectorize function.
- Parameters:
q – a vector of quantiles
mu – the mean
sigma – the standard deviation
skew – the skew parameter
shape – the shape parameter
lower_tail – if TRUE (default), probabilities are P[X ≤ x] otherwise, P[X > x]
- Return type:
a numpy array
- pdqr.qsged(p: ArrayLike, mu: ArrayLike = 0, sigma: ArrayLike = 1, skew: ArrayLike = 2, shape: ArrayLike = 4, lower_tail: bool = True) NDArray[float64][source]
(Skew-GED) Quantile Function (qsged)
In cases when the parameters are vectors of size n (>1), then they must be equal in size to p (unless they are of size 1 in which case they are recycled). This is achieved using the numpy vectorize function.
- Parameters:
p – a vector of probabilities
mu – the mean
sigma – the standard deviation
skew – the skew parameter
shape – the shape parameter
lower_tail – if TRUE (default), probabilities are P[X ≤ x] otherwise, P[X > x]
- Return type:
a numpy array
- pdqr.rsged(n: int = 1, mu: float = 0, sigma: float = 1, skew: float = 2, shape: float = 4, seed: int | None = None) NDArray[float64][source]
(Skew-GED) Random Number Function (rsged)
- Parameters:
n – the number of draws
mu – the mean
sigma – the standard deviation
skew – the skew parameter
shape – the shape parameter
seed – an optional value to initialize the random seed generator
- Return type:
a numpy array
Skew Student’s T distribution
- pdqr.dsstd(x: ArrayLike, mu: ArrayLike = 0, sigma: ArrayLike = 1, skew: ArrayLike = 2, shape: ArrayLike = 4, log: bool = False) NDArray[float64][source]
(Skew-Student) Probability Density Function (dsstd)
In cases when the parameters are vectors of size n (>1), then they must be equal in size to x (unless they are of size 1 in which case they are recycled). This is achieved using the numpy vectorize function.
- Parameters:
x – a vector of quantiles
mu – the mean
sigma – the standard deviation
skew – the skew parameter
shape – the shape parameter
log – whether to return the log density
- Return type:
a numpy array
- pdqr.psstd(q: ArrayLike, mu: ArrayLike = 0, sigma: ArrayLike = 1, skew: ArrayLike = 2, shape: ArrayLike = 4, lower_tail: bool = True) NDArray[float64][source]
(Skew-Student) Cumulative Probability Function (psstd)
In cases when the parameters are vectors of size n (>1), then they must be equal in size to q (unless they are of size 1 in which case they are recycled). This is achieved using the numpy vectorize function.
- Parameters:
q – a vector of quantiles
mu – the mean
sigma – the standard deviation
skew – the skew parameter
shape – the shape parameter
lower_tail – if TRUE (default), probabilities are P[X ≤ x] otherwise, P[X > x]
- Return type:
a numpy array
- pdqr.qsstd(p: ArrayLike, mu: ArrayLike = 0, sigma: ArrayLike = 1, skew: ArrayLike = 2, shape: ArrayLike = 4, lower_tail: bool = True) NDArray[float64][source]
(Skew-Student) Quantile Function (qsstd)
In cases when the parameters are vectors of size n (>1), then they must be equal in size to p (unless they are of size 1 in which case they are recycled). This is achieved using the numpy vectorize function.
- Parameters:
p – a vector of probabilities
mu – the mean
sigma – the standard deviation
skew – the skew parameter
shape – the shape parameter
lower_tail – if TRUE (default), probabilities are P[X ≤ x] otherwise, P[X > x]
- Return type:
a numpy array
- pdqr.rsstd(n: int = 1, mu: float = 0, sigma: float = 1, skew: float = 2, shape: float = 4, seed: int | None = None) NDArray[float64][source]
(Skew-Student) Random Number Function (rsstd)
- Parameters:
n – the number of draws
mu – the mean
sigma – the standard deviation
skew – the skew parameter
shape – the shape parameter
seed – an optional value to initialize the random seed generator
- Return type:
a numpy array
Johnson’s SU distribution
In the original parameterization of Johnson’s SU distribution, the pdf is given by:
for \(-\infty<x<\infty\), \(-\infty<\xi<\infty\), \(\lambda>0\), \(-\infty<\nu^*<\infty\) and \(\tau^*>0\), where
with \(s = \left(x - \xi)/\lambda\right)\).
Reparameterizing the pdf in terms of the mean and standard deviation we set \(\mu = \xi - \lambda\omega^{0.5}\sinh\left(\nu^*/\tau^*\right)\), \(\sigma = \lambda/c\), \(\nu = -\nu^*\) and \(\tau = \tau^*\). Therefore:
for \(-\infty<x<\infty\), \(-\infty<\mu<\infty\), \(\sigma>0\), \(-\infty<\nu<\infty\) and \(\tau>0\), where
The reparameterization is taken from [Rigby et al., 2019] Section 18.4.3 which also contains additional information on the properties of the \(\nu\) and \(\tau\) parameters.
- pdqr.djsu(x: ArrayLike, mu: ArrayLike = 0, sigma: ArrayLike = 1, skew: ArrayLike = 2, shape: ArrayLike = 4, log: bool = False) NDArray[float64][source]
(Johnson’s SU) Probability Density Function (djsu)
In cases when the parameters are vectors of size n (>1), then they must be equal in size to x (unless they are of size 1 in which case they are recycled). This is achieved using the numpy vectorize function.
- Parameters:
x – a vector of quantiles
mu – the mean
sigma – the standard deviation
skew – the skew parameter
shape – the shape parameter
log – whether to return the log density
- Return type:
a numpy array
- pdqr.pjsu(q: ArrayLike, mu: ArrayLike = 0, sigma: ArrayLike = 1, skew: ArrayLike = 2, shape: ArrayLike = 4, lower_tail: bool = True) NDArray[float64][source]
(Johnson’s SU) Cumulative Probability Function (pjsu)
In cases when the parameters are vectors of size n (>1), then they must be equal in size to q (unless they are of size 1 in which case they are recycled). This is achieved using the numpy vectorize function.
- Parameters:
q – a vector of quantiles
mu – the mean
sigma – the standard deviation
skew – the skew parameter
shape – the shape parameter
lower_tail – if TRUE (default), probabilities are P[X ≤ x] otherwise, P[X > x]
- Return type:
a numpy array
- pdqr.qjsu(p: ArrayLike, mu: ArrayLike = 0, sigma: ArrayLike = 1, skew: ArrayLike = 2, shape: ArrayLike = 4, lower_tail: bool = True) NDArray[float64][source]
(Johnson’s SU) Quantile Function (qjsu)
In cases when the parameters are vectors of size n (>1), then they must be equal in size to p (unless they are of size 1 in which case they are recycled). This is achieved using the numpy vectorize function.
- Parameters:
p – a vector of probabilities
mu – the mean
sigma – the standard deviation
skew – the skew parameter
shape – the shape parameter
lower_tail – if TRUE (default), probabilities are P[X ≤ x] otherwise, P[X > x]
- Return type:
a numpy array
- pdqr.rjsu(n: int = 1, mu: float = 0, sigma: float = 1, skew: float = 2, shape: float = 4, seed: int | None = None) NDArray[float64][source]
(Johnson’s SU) Random Number Function (rjsu)
- Parameters:
n – the number of draws
mu – the mean
sigma – the standard deviation
skew – the skew parameter
shape – the shape parameter
seed – an optional value to initialize the random seed generator
- Return type:
a numpy array
Generalized Hyperbolic distribution
In distributions where the expected moments are functions of all the parameters, it is not immediately obvious how to perform such a transformation. In the case of the Generalized Hyperbolic (GH) distribution, because of the existence of location and scale invariant parameterizations and the possibility of expressing the variance in terms of one of those, namely the \((\zeta, \rho)\), the task of standardizing and estimating the density can be broken down to one of estimating those 2 parameters, representing a combination of shape and skewness, followed by a series of transformation steps to demean, scale and then translate the parameters into the \((\alpha, \beta, \delta, \mu)\) parameterization for which standard formula exist for the likelihood function. The \((\xi, \chi)\) parameterization, which is a simple transformation of the \((\zeta, \rho)\), could also be used in the first step and then transformed into the latter before proceeding further. The only difference is the kind of ‘immediate’ inference one can make from the different parameterizations, each providing a different direct insight into the kind of dynamics produced and their place in the overall GH family particularly with regards to the limit cases.
The package performs estimation using the \((\zeta, \rho)\) parameterization, after which a series of steps transform those parameters into the \((\alpha, \beta, \delta, \mu)\) while at the same time including the necessary recursive substitution of parameters in order to standardize the resulting distribution.
Consider the standardized Generalized Hyperbolic Distribution. Let \(\varepsilon_t\) be a r.v. with mean \((0)\) and variance \(({\sigma}^2)\) distributed as \(\textrm{GH}(\zeta, \rho)\), and let \(z\) be a scaled version of the r.v. \(\varepsilon\) with variance \((1)\) and also distributed as \(\textrm{GH}(\zeta, \rho)\) (the parameters \(\zeta\) and \(\rho\) do not change as a result of being location and scale invariant). The density \(f(.)\) of \(z\) can be expressed as
where we make use of the \((\alpha, \beta, \delta, \mu)\) parameterization since we can only naturally express the density in that parameterization. The steps to transforming from the \((\zeta, \rho)\) to the \((\alpha, \beta, \delta, \mu)\) parameterization, while at the same time standardizing for zero mean and unit variance are given henceforth. Let
which after some substitution may be also written in terms of \(\alpha\) and \(\beta\) as,
For standardization we require that,
Since we can express, \(\beta^2/\left(\alpha^2 - \beta^2\right)\) as,
then we can re-write the formula for \(\delta\) in terms of the estimated parameters \(\hat\zeta\) and \(\hat\rho\) as,
Transforming into the \((\tilde \alpha ,\tilde \beta ,\tilde \delta ,\tilde \mu )\) parameterization proceeds by first substituting the above value of \(\delta\) into the equation for \(\alpha\) and simplifying:
Finally, the rest of the parameters are derived recursively from \(\tilde\alpha\) and the previous results,
For the use of the \((\xi, \chi)\) parameterization in estimation, the additional preliminary steps of converting to the \((\zeta, \rho)\) are,
- pdqr.dsgh(x: ArrayLike, mu: ArrayLike = 0, sigma: ArrayLike = 1, skew: ArrayLike = 0.5, shape: ArrayLike = 4, lamda: ArrayLike = 0, log: bool = False) NDArray[float64][source]
(Standardized Generalized Hyperbolic) Probability Density Function (dsgh)
In cases when the parameters are vectors of size n (>1), then they must be equal in size to x (unless they are of size 1 in which case they are recycled). This is achieved using the numpy vectorize function.
- Parameters:
x – a vector of quantiles
mu – the mean
sigma – the standard deviation
skew – the skew parameter
shape – the shape parameter
lamda – the second shape parameter of the GH distribution related to the GIG distribution.
log – whether to return the log density
- Return type:
a numpy array
- pdqr.psgh(q: ArrayLike, mu: ArrayLike = 0, sigma: ArrayLike = 1, skew: ArrayLike = 0.5, shape: ArrayLike = 4, lamda: ArrayLike = 0, lower_tail: bool = True) NDArray[float64][source]
(Standardized Generalized Hyperbolic) Cumulative Probability Function (psgh)
In cases when the parameters are vectors of size n (>1), then they must be equal in size to q (unless they are of size 1 in which case they are recycled). This is achieved using the numpy vectorize function.
- Parameters:
q – a vector of quantiles
mu – the mean
sigma – the standard deviation
skew – the skew parameter
shape – the shape parameter
lamda – the second shape parameter of the GH distribution related to the GIG distribution.
lower_tail – if TRUE (default), probabilities are P[X ≤ x] otherwise, P[X > x]
- Return type:
a numpy array
- pdqr.qsgh(p: ArrayLike, mu: ArrayLike = 0, sigma: ArrayLike = 1, skew: ArrayLike = 0.5, shape: ArrayLike = 4, lamda: ArrayLike = 0, lower_tail: bool = True) NDArray[float64][source]
(Standardized Generalized Hyperbolic) Quantile Function (qsgh)
In cases when the parameters are vectors of size n (>1), then they must be equal in size to p (unless they are of size 1 in which case they are recycled). This is achieved using the numpy vectorize function.
- Parameters:
p – a vector of probabilities
mu – the mean
sigma – the standard deviation
skew – the skew parameter
shape – the shape parameter
lamda – the second shape parameter of the GH distribution related to the GIG distribution.
lower_tail – if TRUE (default), probabilities are P[X ≤ x] otherwise, P[X > x]
- Return type:
a numpy array
- pdqr.rsgh(n: int = 1, mu: float = 0, sigma: float = 1, skew: float = 0.5, shape: float = 4, lamda: float = 0, seed: int | None = None) NDArray[float64][source]
(Standardized Generalized Hyperbolic) Random Number Function (rsgh)
- Parameters:
n – the number of draws
mu – the mean
sigma – the standard deviation
skew – the skew parameter
shape – the shape parameter
lamda – the second shape parameter of the GH distribution related to the GIG distribution.
seed – an optional value to initialize the random seed generator
- Return type:
a numpy array
Generalized Hyperbolic Skew Student’s T distribution
The GH Skew-Student distribution was popularized by [Aas and Haff, 2006] because of its uniqueness in the GH family in having one tail with polynomial and one with exponential behavior. This distribution is a limiting case of the GH when \(\alpha \to \left| \beta \right|\) and \(\lambda=-\nu/2\), where \(\nu\) is the shape parameter of the Student distribution. The domain of variation of the parameters is \(\beta \in \mathbb{R}\) and \(\nu>0\), but for the variance to be finite \(\nu>4\), while for the existence of skewness and kurtosis, \(\nu>6\) and \(\nu>8\) respectively. The density of the random variable \(x\) is then given by:
To standardize the distribution to have zero mean and unit variance, I make use of the first two moment conditions for the distribution which are:
We require that \(Var(x)=1\), thus:
where I have made use of the \(4^{th}\) parameterization of the GH distribution given in [Prause, 1999] where \(\hat \beta = \beta \delta\). The location parameter is then rescaled by substituting into the first moment formula \(\delta\) so that it has zero mean:
Therefore, we model the GH Skew-Student using the location-scale invariant parameterization \((\bar \beta, \nu)\) and then translate the parameters into the usual GH distribution’s \((\alpha, \beta, \delta, \mu)\), setting \(\alpha = abs(\beta)+1e-12\).
- pdqr.dsghst(x: ArrayLike, mu: ArrayLike = 0, sigma: ArrayLike = 1, skew: ArrayLike = 2, shape: ArrayLike = 4, log: bool = False) NDArray[float64][source]
(Standardized Generalized Hyperbolic Skew Student) Probability Density Function (dsghst)
In cases when the parameters are vectors of size n (>1), then they must be equal in size to x (unless they are of size 1 in which case they are recycled). This is achieved using the numpy vectorize function.
- Parameters:
x – a vector of quantiles
mu – the mean
sigma – the standard deviation
skew – the skew parameter
shape – the shape parameter
log – whether to return the log density
- Return type:
a numpy array
- pdqr.psghst(q: ArrayLike, mu: ArrayLike = 0, sigma: ArrayLike = 1, skew: ArrayLike = 2, shape: ArrayLike = 4, lower_tail: bool = True) NDArray[float64][source]
(Standardized Generalized Hyperbolic Skew Student) Cumulative Probability Function (psghst)
In cases when the parameters are vectors of size n (>1), then they must be equal in size to q (unless they are of size 1 in which case they are recycled). This is achieved using the numpy vectorize function.
- Parameters:
q – a vector of quantiles
mu – the mean
sigma – the standard deviation
skew – the skew parameter
shape – the shape parameter
lower_tail – if TRUE (default), probabilities are P[X ≤ x] otherwise, P[X > x]
- Return type:
a numpy array
- pdqr.qsghst(p: ArrayLike, mu: ArrayLike = 0, sigma: ArrayLike = 1, skew: ArrayLike = 2, shape: ArrayLike = 4, lower_tail: bool = True) NDArray[float64][source]
(Standardized Generalized Hyperbolic Skew Student) Quantile Function (qsghst)
In cases when the parameters are vectors of size n (>1), then they must be equal in size to p (unless they are of size 1 in which case they are recycled). This is achieved using the numpy vectorize function.
- Parameters:
p – a vector of probabilities
mu – the mean
sigma – the standard deviation
skew – the skew parameter
shape – the shape parameter
lower_tail – if TRUE (default), probabilities are P[X ≤ x] otherwise, P[X > x]
- Return type:
a numpy array
- pdqr.rsghst(n: int = 1, mu: float = 0, sigma: float = 1, skew: float = 2, shape: float = 4, seed: int | None = None) NDArray[float64][source]
(Standardized Generalized Hyperbolic Skew Student) Random Number Function (rsghst)
- Parameters:
p – a vector of probabilities
mu – the mean
sigma – the standard deviation
skew – the skew parameter
shape – the shape parameter
seed – an optional value to initialize the random seed generator
- Return type:
a numpy array