Boost: Hyperexponential Distribution#
The following functions return pdf, cdf, qtf or boost class of the hyperexponential distribution with weights \(w_j > 0\), rate parameters \(\lambda_j > 0\), \(j=1 \ldots k\), and the support interval \((0, +\infty)\). The weights are interpreted as relative weights, to ensure that \(\sum_{j=1}^{k} w_j = 1\).
See also Wikipedia [1270], MathWorld [256], BoostMath [83].
- Ctx.hyperexponential_pdf(x, lambdaj)#
where
CtxisMath53orCtxBoost.Returns \(\text{pdf}(x)\), the value of the probability density function (Pdf) of the hyperexponential distribution:
\[\text{pdf}(x) = \sum_{j=1}^{k} w_j \cdot \lambda_j e^{-\lambda_j x}.\]The following example shows both forms of the syntax:
>>> from mpfebnet import * >>> a = 0; b = 1; t = 0.3; x = 0.6; >>> print ("HyperexpPdf(x, a, b): ", HyperexpPdf(x, a, b)) >>> print ("dist_hyperexponential(a, b).pdf(x): ", dist_hyperexponential(a, b).pdf(x)) 6.3563523462564525615615615614561356E+00
- Ctx.hyperexponential_cdf(x, lambdaj)#
where
CtxisMath53orCtxBoost.Returns \(\text{cdf}(x)\), the value of the cumulative distribution function (Cdf) of the hyperexponential distribution:
\[\text{cdf}(x) = \sum_{j=1}^{k} w_j (1-e^{-\lambda_j x}) = -\sum_{j=1}^{k} w_j \cdot \mathrm{expm1}(-\lambda_j x).\]The following example shows both forms of the syntax:
>>> from mpfebnet import * >>> a = 0; b = 1; t = 0.3; x = 0.6; >>> print ("HyperexpCdf(x, a, b): ", HyperexpCdf(x, a, b)) >>> print ("dist_hyperexponential(a, b).cdf(x): ", dist_hyperexponential(a, b).cdf(x)) 6.3563523462564525615615615614561356E+00
- Ctx.hyperexponential_qtf(q, lambdaj)#
where
CtxisMath53orCtxBoost.Returns \(\text{qtf}(q)\), the value of the quantile function (Qtf) of the hyperexponential distribution:
There is no known closed form for \(\text{qtf}(q)\). The function is computed with the starting value \(x_0 = -\mathrm{log1p}(-q) \sum_{j=1}^{k} (w_j/\lambda_j)\) using Newton iterations.
The following example shows both forms of the syntax:
>>> from mpfebnet import * >>> a = 0; b = 1; t = 0.3; q = 0.6; >>> print ("HyperexpQtf(q, a, b): ", HyperexpQtf(q, a, b)) >>> print ("dist_hyperexponential(a, b).qtf(q): ", dist_hyperexponential(a, b).qtf(q)) 6.3563523462564525615615615614561356E+00
- class ctx.dist_hyperexponential(k, wj, lambdaj)#
where
ctxisfpm,mpm,ipm,dec,gmporapm.The hyperexponential distribution is a continuous probability mixture distribution with weights \(w_j > 0\), rate parameters \(\lambda_j > 0\), \(j=1 \ldots k\), and the support interval \((0, +\infty)\). The weights are interpreted as relative weights, to ensure that \(\sum_{j=1}^{k} w_j = 1\).
It is called the hyperexponential distribution as it has a coefficient of variation greater than one, compared to the hypoexponential distribution which has coefficient of variation less than one and the exponential distribution which has coefficient of variation of one.
- dist_hyperexponential.pdf(x)#
Returns \(\text{pdf}_X(x)\), the probability density function (pdf) of a random variable \(X\), following a hyperexponential distribution:
\[\text{pdf}_X(x) = \sum_{j=1}^{k} w_j \cdot \lambda_j e^{-\lambda_j x}.\]>>> from mpfunlab import * >>> mp.dps = 30 >>> mu = 0; sigma = 1; x = 3; >>> print ("pdf: ", mp_hyperexponential(mu, sigma).pdf(x)) 6.3563523462564525615615615614561356E-20
- dist_hyperexponential.cdf(x)#
Returns \(\text{cdf}_X(x)\), the cumulative distribution function (cdf) of a random variable \(X\), following a hyperexponential distribution:
\[\text{cdf}_X(x) = \sum_{j=1}^{k} w_j (1-e^{-\lambda_j x}) = -\sum_{j=1}^{k} w_j \cdot \mathrm{expm1}(-\lambda_j x).\]>>> from mpfunlab import * >>> mp.dps = 30 >>> mu = 0; sigma = 1; x = 3; >>> print ("cdf: ", mp_hyperexponential(mu, sigma).pdf(x)) 6.3563523462564525615615615614561356E-20
- dist_hyperexponential.sf(x)#
Returns \(\text{sf}_X(x)\), the survival function function (sf) of a random variable \(X\), following a hyperexponential distribution:
\[\text{sf}_X(x) = 1 - \sum_{j=1}^{k} w_j (1-e^{-\lambda_j x}) = \sum_{j=1}^{k} w_j \cdot \exp(-\lambda_j x).\]>>> from mpfunlab import * >>> mp.dps = 30 >>> mu = 0; sigma = 1; x = 3; >>> print (" sf: ", mp_hyperexponential(mu, sigma).pdf(x)) sf: 6.3563523462564525615615615614561356E-20
- dist_hyperexponential.qtf(q)#
Returns \(\text{qtf}_X(x)\), the quantile function function (qtf) of a random variable \(X\), following a hyperexponential distribution.
There is no known closed form for \(\text{qtf}_X(q)\). The function is computed with the starting value \(x_0 = -\mathrm{log1p}(-q) \sum_{j=1}^{k} (w_j/\lambda_j)\) using Newton iterations.
>>> from mpfunlab import * >>> mp.dps = 30 >>> mu = 0; sigma = 1; q = 0.3; >>> print ("qtf: ", mp_hyperexponential(mu, sigma).qtf(q)) qtf: 6.3563523462564525615615615614561356E+00
- dist_hyperexponential.isf(q)#
Returns \(\text{isf}_X(q)\), the inverse survival function function (isf) of a random variable \(X\), following a hyperexponential distribution.
There is no known closed form for \(\text{isf}_X(q)\). The function is computed with the starting value \(x_0 = -\log(q) \sum_{j=1}^{k} (w_j/\lambda_j)\) using Newton iterations.
>>> from mpfunlab import * >>> mp.dps = 30 >>> mu = 0; sigma = 1; q = 0.3; >>> print ("isf: ", mp_hyperexponential(mu, sigma).isf(q)) 6.3563523462564525615615615614561356E+00
- dist_hyperexponential.c_x(t)#
Returns \(C_X(t)\), the characteristic function of a random variable \(X\), following a hyperexponential distribution:
\[C_X(t) = \sum_{j=1}^{k} w_j \frac{\lambda_j}{\lambda_j - it}.\]>>> from mpfunlab import * >>> mp.dps = 30 >>> mu = 0; sigma = 1; t = 0.3; >>> print ("c_x: ", mp_hyperexponential(mu, sigma).c_x(t)) 6.3563523462564525615615615614561356E+00
- dist_hyperexponential.m_x(t)#
Returns \(M_X(t)\), the moment generating function of a random variable \(X\), following a hyperexponential distribution:
\[M_X(t) = \sum_{j=1}^{k} w_j \frac{\lambda_j}{\lambda_j - t}, \quad \text{for } \min(\lambda_j)>t.\]>>> from mpfunlab import * >>> mp.dps = 30 >>> mu = 0; sigma = 1; t = 0.3; >>> print ("c_x: ", mp_hyperexponential(mu, sigma).c_x(t)) 6.3563523462564525615615615614561356E+00
- dist_hyperexponential.k_x(t, k=0)#
Returns \(K_X(t)\), the cumulant generating function of a random variable \(X\), following a hyperexponential distribution:
\[K_X(t) = \log \left[ \sum_{j=1}^{k} w_j \frac{\lambda_j}{\lambda_j - t} \right], \quad \text{for } \min(\lambda_j)>t.\]>>> from mpfunlab import * >>> mp.dps = 30 >>> mu = 0; sigma = 1; t = 0.3; k = 6; >>> print ("c_x: ", mp_hyperexponential(mu, sigma).k_x(t, k)) 6.3563523462564525615615615614561356E+00
- dist_hyperexponential.moments(k)#
Returns the first \(j\) raw moments, \(\mu_j, j = 1 \ldots k\), of a random variable \(X\), following a hyperexponential distribution:
\[\mu_{X}(r) = r! \sum_{j=1}^{k}\frac{w_j}{\lambda_j^r}\]>>> from mpfunlab import * >>> mp.dps = 30 >>> mu = 0; sigma = 1; k = 6; >>> print ("saddlepoint: ", mp_hyperexponential(mu, sigma).moments(k)) 6.3563523462564525615615615614561356E+00
- dist_hyperexponential.cumulants(k)#
Returns the first \(j\) cumulants, \(\kappa_j, j = 1 \ldots k\), of a random variable \(X\), following a hyperexponential distribution. The cumulants are calculated from the moments.
>>> from mpfunlab import * >>> mp.dps = 30 >>> mu = 0; sigma = 1; k = 6; >>> print ("saddlepoint: ", mp_hyperexponential(mu, sigma).cumulants(k)) 6.3563523462564525615615615614561356E+00