Boost: Gamma (Pearson Type III, Erlang) distribution#

The following functions return the pdf, cdf, qtf or boost class of the gamma distribution with shape \(a > 0\), scale \(b > 0\), and the support interval \((0,+\infty)\).

See also Wikipedia [1244], MathWorld [893], BoostMath [63], Ehrhardt [309] (3.9.10).

Ctx.gamma_pdf(x, a=0, b=1)#

where Ctx is Math53 or CtxBoost.

Returns \(\text{pdf}(x)\), the value of the probability density function (Pdf) of the gamma distribution:

\[\text{pdf}(x) = \frac{x^{a-1}e^{-x/b}}{\Gamma(a) b^a}.\]

The following example shows both forms of the syntax:

>>> from mpfebnet import *
>>> a = 0; b = 1; t = 0.3; x = 0.6;
>>> print ("GammaPdf(x, a, b): ", GammaPdf(x, a, b))
>>> print ("dist_gamma(a, b).pdf(x): ", dist_gamma(a, b).pdf(x))
6.3563523462564525615615615614561356E+00

Ctx.gamma_cdf(x, a=0, b=1)#

where Ctx is Math53 or CtxBoost.

Returns \(\text{cdf}(x)\), the value of the cumulative distribution function (Cdf) of the gamma distribution:

\[\text{cdf}(x) = P(a,x/b).\]

Here \(P(\cdot)\) denotes the lower regularized incomplete gamma function (RealGammaP).

The following example shows both forms of the syntax:

>>> from mpfebnet import *
>>> a = 0; b = 1; t = 0.3; x = 0.6;
>>> print ("GammaCdf(x, a, b): ", GammaCdf(x, a, b))
>>> print ("dist_gamma(a, b).cdf(x): ", dist_gamma(a, b).cdf(x))
6.3563523462564525615615615614561356E+00

Ctx.gamma_qtf(q, a=0, b=1)#

where Ctx is Math53 or CtxBoost.

Returns \(\text{qtf}(q)\), the value of the quantile function (Qtf) of the gamma distribution:

\[\text{qtf}(q) = b \cdot P^{-1}(a,q).\]

Here \(P^{-1}(\cdot)\) denotes the inverse of the lower regularized incomplete gamma function (RealGammaPInv).

The following example shows both forms of the syntax:

>>> from mpfebnet import *
>>> a = 0; b = 1; t = 0.3; q = 0.6;
>>> print ("GammaQtf(q, a, b): ", GammaQtf(q, a, b))
>>> print ("dist_gamma(a, b).qtf(q): ", dist_gamma(a, b).qtf(q))
6.3563523462564525615615615614561356E+00

class ctx.dist_gamma(a, b)#

where ctx is fpm, mpm, ipm, dec, gmp or apm.

The gamma distribution is a continuous probability distribution with shape \(a > 0\), scale \(b > 0\), and the support interval \((0,+\infty)\). See also Wikipedia [1244], MathWorld [893], BoostMath [63], Witkovský [1618], R (Statistical System) [550].

See also: https://docs.scipy.org/doc/scipy/reference/generated/scipy.special.gdtr.html#scipy.special.gdtr

See also: https://docs.scipy.org/doc/scipy/reference/generated/scipy.special.gdtrc.html#scipy.special.gdtrc

See also: https://docs.scipy.org/doc/scipy/reference/generated/scipy.special.gdtrib.html#scipy.special.gdtrib

See also: https://docs.scipy.org/doc/scipy/reference/generated/scipy.special.gdtrix.html#scipy.special.gdtrix

dist_gamma.pdf(x)#

Returns \(\text{pdf}_X(x)\), the probability density function (pdf) of a random variable \(X\), following a gamma distribution:

\[\text{pdf}_X(x) = \frac{x^{a-1}e^{-x/b}}{\Gamma(a) b^a}.\]
>>> from mpfunlab import *
>>> mp.dps = 30
>>> mu = 0; sigma = 1; x = 3;
>>> print ("pdf: ", gamma(mu, sigma).pdf(x))
6.3563523462564525615615615614561356E-20

dist_gamma.cdf(x)#

Returns \(\text{cdf}_X(x)\), the cumulative distribution function (cdf) of a random variable \(X\), following a gamma distribution:

\[\text{cdf}_X(x) = P(a,x/b).\]
>>> from mpfunlab import *
>>> mp.dps = 30
>>> mu = 0; sigma = 1; x = 3;
>>> print ("cdf: ", gamma(mu, sigma).pdf(x))
6.3563523462564525615615615614561356E-20

dist_gamma.sf(x)#

Returns \(\text{sf}_X(x)\), the survival function (sf) of a random variable \(X\), following a gamma distribution:

\[\text{sf}_X(x) = Q(a,x/b).\]
>>> from mpfunlab import *
>>> mp.dps = 30
>>> mu = 0; sigma = 1; x = 3;
>>> print (" sf: ", gamma(mu, sigma).pdf(x))
sf: 6.3563523462564525615615615614561356E-20

dist_gamma.qtf(q)#

Returns \(\text{qtf}_X(x)\), the quantile function (qtf) of a random variable \(X\), following a gamma distribution:

\[\text{qtf}_X(q) = b \cdot P^{-1}(a,q).\]
>>> from mpfunlab import *
>>> mp.dps = 30
>>> mu = 0; sigma = 1; q = 0.3;
>>> print ("qtf: ", gamma(mu, sigma).qtf(q))
qtf: 6.3563523462564525615615615614561356E+00

dist_gamma.isf(q)#

Returns \(\text{isf}_X(q)\), the inverse survival function (isf) of a random variable \(X\), following a gamma distribution:

\[\text{isf}_X(q) = b \cdot Q^{-1}(a,q).\]
>>> from mpfunlab import *
>>> mp.dps = 30
>>> mu = 0; sigma = 1; q = 0.3;
>>> print ("isf: ", gamma(mu, sigma).isf(q))
6.3563523462564525615615615614561356E+00

dist_gamma.c_x(t)#

Returns \(C_X(t)\), the characteristic function of a random variable \(X\), following a gamma distribution:

\[C_X(t) = \left( \frac{b^{-1}}{(b^{-1}-it)} \right) ^a.\]
>>> from mpfunlab import *
>>> mp.dps = 30
>>> mu = 0; sigma = 1; t = 0.3;
>>> print ("c_x: ", gamma(mu, sigma).c_x(t))
6.3563523462564525615615615614561356E+00

dist_gamma.m_x(t)#

Returns \(M_X(t)\), the moment generating function of a random variable \(X\), following a gamma distribution:

\[M_X(t) = \left( \frac{b^{-1}}{(b^{-1}-t)} \right) ^a.\]
>>> from mpfunlab import *
>>> mp.dps = 30
>>> mu = 0; sigma = 1; t = 0.3;
>>> print ("m_x: ", gamma(mu, sigma).c_x(t))
6.3563523462564525615615615614561356E+00

dist_gamma.k_x(t, k=0)#

Returns \(K_X(t)\), the cumulant generating function of a random variable \(X\), following a gamma distribution:

\[K_X(t) = a \log \left( \frac{b^{-1}}{(b^{-1}-t)} \right).\]
>>> from mpfunlab import *
>>> mp.dps = 30
>>> mu = 0; sigma = 1; t = 0.3; k = 6;
>>> print ("c_x: ", gamma(mu, sigma).k_x(t, k))
6.3563523462564525615615615614561356E+00

dist_gamma.moments(k)#

Returns the first \(j\) raw moments, \(\mu_j, j = 1 \ldots k\), of a random variable \(X\), following an exponential distribution. The rth moments only exists for \(n_2 > 2r\).

\[\mu'_{X}(r) = b^r \frac{\Gamma(a + r)}{\Gamma(a)}.\]
>>> from mpfunlab import *
>>> mp.dps = 30
>>> mu = 0; sigma = 1; k = 6;
>>> print ("saddlepoint: ", gamma(mu, sigma).moments(k))
6.3563523462564525615615615614561356E+00

dist_gamma.cumulants(k)#

Returns the first \(j\) cumulants, \(\kappa_j, j = 1 \ldots k\), of a random variable \(X\), following an exponential distribution. The cumulants are calculated from the moments.

\[\kappa'_{X}(r) = a \cdot b \cdot \Gamma(r).\]
>>> from mpfunlab import *
>>> mp.dps = 30
>>> mu = 0; sigma = 1; k = 6;
>>> print ("saddlepoint: ", gamma(mu, sigma).cumulants(k))
6.3563523462564525615615615614561356E+00