Gamma distribution explained

Gamma
Type:density
Parameters:
Support:

x\in(0,infty)

Pdf:
f(x)=1
\Gamma(k)\thetak

xke-x/\theta

Cdf:
F(x)=1
\Gamma(k)

\gamma\left(k,

x
\theta

\right)

Mean:

k\theta

Median:No simple closed form
Mode:

(k-1)\thetafork\geq1

,

0fork<1

Variance:

k\theta2

Skewness:
2
\sqrt{k
}
Kurtosis:
6
k
Entropy:

\begin{align} k&+ln\theta+ln\Gamma(k)\\ &+(1-k)\psi(k) \end{align}

Mgf:

(1-\thetat)-kfort<

1
\theta
Char:

(1-\thetait)-k

Support2:

x\in(0,infty)

Pdf2:
f(x)=\beta\alpha
\Gamma(\alpha)

x\alphae-\beta

Cdf2:
F(x)=1
\Gamma(\alpha)

\gamma(\alpha,\betax)

Mean2:
\alpha
\beta
Median2:No simple closed form
Mode2:
\alpha-1
\beta

for\alpha\geq1,0for\alpha<1

Variance2:
\alpha
\beta2
Skewness2:
2
\sqrt{\alpha
}
Kurtosis2:
6
\alpha
Entropy2:

\begin{align} \alpha&-ln\beta+ln\Gamma(\alpha)\\ &+(1-\alpha)\psi(\alpha) \end{align}

Mgf2:

\left(1-

t
\beta

\right)-\alphafort<\beta

Char2:

\left(1-

it
\beta

\right)-\alpha

Moments:

k=

E[X]2
V[X]

\theta=

V[X]
E[X]

Moments2:

\alpha=

E[X]2
V[X]

\beta=

E[X]
V[X]

Fisher:

I(k,\theta)=\begin{pmatrix}\psi(1)(k)&\theta-1\\theta-1&k\theta-2\end{pmatrix}

Fisher2:

I(\alpha,\beta)=\begin{pmatrix}\psi(1)(\alpha)&-\beta-1\ -\beta-1&\alpha\beta-2\end{pmatrix}

In probability theory and statistics, the gamma distribution is a versatile two-parameter family of continuous probability distributions. The exponential distribution, Erlang distribution, and chi-squared distribution are special cases of the gamma distribution. There are two equivalent parameterizations in common use:

    1. With a shape parameter and a scale parameter With a shape parameter

\alpha=k

and an inverse scale parameter, called a rate parameter.In each of these forms, both parameters are positive real numbers.

The distribution has important applications in various fields, including econometrics, Bayesian statistics, life testing. In econometrics, the (k, θ) parameterization is common for modeling waiting times, such as the time until death, where it often takes the form of an Erlang distribution for integer k values. Bayesian statistics prefer the (α, β) parameterization, utilizing the gamma distribution as a conjugate prior for several inverse scale parameters, facilitating analytical tractability in posterior distribution computations. The probability density and cumulative distribution functions of the gamma distribution vary based on the chosen parameterization, both offering insights into the behavior of gamma-distributed random variables. The gamma distribution is integral to modeling a range of phenomena due to its flexible shape, which can capture various statistical distributions, including the exponential and chi-squared distributions under specific conditions. Its mathematical properties, such as mean, variance, skewness, and higher moments, provide a toolset for statistical analysis and inference. Practical applications of the distribution span several disciplines, underscoring its importance in theoretical and applied statistics.

The gamma distribution is the maximum entropy probability distribution (both with respect to a uniform base measure and a

1/x

base measure) for a random variable for which is fixed and greater than zero, and is fixed (is the digamma function).[1]

Definitions

The parameterization with and appears to be more common in econometrics and other applied fields, where the gamma distribution is frequently used to model waiting times. For instance, in life testing, the waiting time until death is a random variable that is frequently modeled with a gamma distribution. See Hogg and Craig[2] for an explicit motivation.

The parameterization with and is more common in Bayesian statistics, where the gamma distribution is used as a conjugate prior distribution for various types of inverse scale (rate) parameters, such as the of an exponential distribution or a Poisson distribution[3] – or for that matter, the of the gamma distribution itself. The closely related inverse-gamma distribution is used as a conjugate prior for scale parameters, such as the variance of a normal distribution.

If is a positive integer, then the distribution represents an Erlang distribution; i.e., the sum of independent exponentially distributed random variables, each of which has a mean of .

Characterization using shape α and rate β

The gamma distribution can be parameterized in terms of a shape parameter and an inverse scale parameter, called a rate parameter. A random variable that is gamma-distributed with shape and rate is denoted

X\sim\Gamma(\alpha,\beta)\equiv\operatorname{Gamma}(\alpha,\beta)

The corresponding probability density function in the shape-rate parameterization is

\begin{align} f(x;\alpha,\beta)&=

x\alpha-1e-\beta\beta\alpha
\Gamma(\alpha)

forx>0\alpha,\beta>0,\\[6pt] \end{align}

where

\Gamma(\alpha)

is the gamma function.For all positive integers,

\Gamma(\alpha)=(\alpha-1)!

.

The cumulative distribution function is the regularized gamma function:

F(x;\alpha,\beta)=

x
\int
0

f(u;\alpha,\beta)du=

\gamma(\alpha,\betax)
\Gamma(\alpha)

,

where

\gamma(\alpha,\betax)

is the lower incomplete gamma function.

If is a positive integer (i.e., the distribution is an Erlang distribution), the cumulative distribution function has the following series expansion:

F(x;\alpha,\beta)=

\alpha-1
1-\sum
i=0
(\betax)i
i!

e-\beta=e-\beta

infty
\sum
i=\alpha
(\betax)i
i!

.

Characterization using shape k and scale θ

A random variable that is gamma-distributed with shape and scale is denoted by

X\sim\Gamma(k,\theta)\equiv\operatorname{Gamma}(k,\theta)

The probability density function using the shape-scale parametrization is

f(x;k,\theta)=

xk-1e-x/\theta
\thetak\Gamma(k)

forx>0andk,\theta>0.

Here is the gamma function evaluated at .

The cumulative distribution function is the regularized gamma function:

F(x;k,\theta)=

x
\int
0

f(u;k,\theta)du=

\gamma\left(k,
x
\theta
\right)
\Gamma(k)

,

where

\gamma\left(k,

x
\theta

\right)

is the lower incomplete gamma function.

It can also be expressed as follows, if is a positive integer (i.e., the distribution is an Erlang distribution):[4]

F(x;k,\theta)=

k-1
1-\sum
i=0
1\left(
i!
x
\theta

\right)ie-x/\theta=e-x/\theta

infty
\sum
i=k
1
i!

\left(

x
\theta

\right)i.

Both parametrizations are common because either can be more convenient depending on the situation.

Properties

Mean and variance

The mean of gamma distribution is given by the product of its shape and scale parameters:

\mu=k\theta=\alpha/\beta

The variance is:

\sigma2=k\theta2=\alpha/\beta2

The square root of the inverse shape parameter gives the coefficient of variation:

\sigma/\mu=k-0.5=1/\sqrt{\alpha}

Skewness

The skewness of the gamma distribution only depends on its shape parameter,, and it is equal to

2/\sqrt{k}.

Higher moments

The -th raw moment is given by:

E[Xn]=\thetan

\Gamma(k+n)
\Gamma(k)

=\thetan

n(k+i-1)
\prod
i=1

forn=1,2,\ldots.

Median approximations and bounds

Unlike the mode and the mean, which have readily calculable formulas based on the parameters, the median does not have a closed-form equation. The median for this distribution is the value such that

1
\Gamma(k)\thetak
\nu
\int
0

xke-x/\thetadx=

1
2

.

A rigorous treatment of the problem of determining an asymptotic expansion and bounds for the median of the gamma distribution was handled first by Chen and Rubin, who proved that (for

\theta=1

)

k-

1
3

<\nu(k)<k,

where

\mu(k)=k

is the mean and

\nu(k)

is the median of the

Gamma(k,1)

distribution.[5] For other values of the scale parameter, the mean scales to

\mu=k\theta

, and the median bounds and approximations would be similarly scaled by .

K. P. Choi found the first five terms in a Laurent series asymptotic approximation of the median by comparing the median to Ramanujan's

\theta

function.[6] Berg and Pedersen found more terms:[7]

\nu(k)=k-

1
3

+

8
405k

+

184
25515k2

+

2248
3444525k3

-

19006408
15345358875k4

-O\left(

1
k5

\right)+

Partial sums of these series are good approximations for high enough ; they are not plotted in the figure, which is focused on the low- region that is less well approximated.

Berg and Pedersen also proved many properties of the median, showing that it is a convex function of,[8] and that the asymptotic behavior near

k=0

is

\nu(k)e-\gamma2-1/k

(where is the Euler–Mascheroni constant), and that for all

k>0

the median is bounded by

k2-1/k<\nu(k)<ke-1/3k

.[7]

A closer linear upper bound, for

k\ge1

only, was provided in 2021 by Gaunt and Merkle,[9] relying on the Berg and Pedersen result that the slope of

\nu(k)

is everywhere less than 1:

\nu(k)\lek-1+log2~~

for

k\ge1

(with equality at

k=1

)which can be extended to a bound for all

k>0

by taking the max with the chord shown in the figure, since the median was proved convex.[8]

An approximation to the median that is asymptotically accurate at high and reasonable down to

k=0.5

or a bit lower follows from the Wilson–Hilferty transformation:

\nu(k)=k\left(1-

1
9k

\right)3

which goes negative for

k<1/9

.

In 2021, Lyon proposed several approximations of the form

\nu(k)2-1/k(A+Bk)

. He conjectured values of and for which this approximation is an asymptotically tight upper or lower bound for all

k>0

.[10] In particular, he proposed these closed-form bounds, which he proved in 2023:[11]

\nuLinfty(k)=2-1/k(log2-

1
3

+k)

is a lower bound, asymptotically tight as

k\toinfty

\nuU(k)=2-1/k(e-\gamma+k)

is an upper bound, asymptotically tight as

k\to0

Lyon also showed (informally in 2021, rigorously in 2023) two other lower bounds that are not closed-form expressions, including this one involving the gamma function, based on solving the integral expression substituting 1 for

e-x

:

\nu(k)>\left(

2
\Gamma(k+1)

\right)-1/k

(approaching equality as

k\to0

)and the tangent line at

k=1

where the derivative was found to be

\nu\prime(1)0.9680448

:

\nu(k)\ge\nu(1)+(k-1)\nu\prime(1)

(with equality at

k=1

)

\nu(k)\gelog2+(k-1)(\gamma-2\operatorname{Ei}(-log2)-loglog2)

where Ei is the exponential integral.[10] [11]

Additionally, he showed that interpolations between bounds could provide excellent approximations or tighter bounds to the median, including an approximation that is exact at

k=1

(where

\nu(1)=log2

) and has a maximum relative error less than 0.6%. Interpolated approximations and bounds are all of the form

\nu(k)\tilde{g}(k)\nuLinfty(k)+(1-\tilde{g}(k))\nuU(k)

where

\tilde{g}

is an interpolating function running monotonically from 0 at low to 1 at high, approximating an ideal, or exact, interpolator

g(k)

:

g(k)=

\nuU(k)-\nu(k)
\nuU(k)-\nuLinfty(k)
For the simplest interpolating function considered, a first-order rational function

\tilde{g}1(k)=

k
b0+k
the tightest lower bound has

b0=

8+e-\gammalog2-
log22
2
405
-\gamma
e-log2+
1
3

-log20.143472

and the tightest upper bound has

b0=

-\gamma
e-log2+
1
3
1-
e-\gamma\pi2
12

0.374654

The interpolated bounds are plotted (mostly inside the yellow region) in the log–log plot shown. Even tighter bounds are available using different interpolating functions, but not usually with closed-form parameters like these.[10]

Summation

If has a distribution for (i.e., all distributions have the same scale parameter), then

N
\sum
i=1

Xi\simGamma\left(

N
\sum
i=1

ki,\theta\right)

provided all are independent.

For the cases where the are independent but have different scale parameters, see Mathai [12] or Moschopoulos.[13]

The gamma distribution exhibits infinite divisibility.

Scaling

If

X\simGamma(k,\theta),

then, for any,

cX\simGamma(k,c\theta),

by moment generating functions,

or equivalently, if

X\simGamma\left(\alpha,\beta\right)

(shape-rate parameterization)

cX\simGamma\left(\alpha,

\beta
c

\right),

Indeed, we know that if is an exponential r.v. with rate, then is an exponential r.v. with rate ; the same thing is valid with Gamma variates (and this can be checked using the moment-generating function, see, e.g.,these notes, 10.4-(ii)): multiplication by a positive constant divides the rate (or, equivalently, multiplies the scale).

Exponential family

The gamma distribution is a two-parameter exponential family with natural parameters and (equivalently, and), and natural statistics and .

If the shape parameter is held fixed, the resulting one-parameter family of distributions is a natural exponential family.

Logarithmic expectation and variance

One can show that

\operatorname{E}[lnX]=\psi(\alpha)-ln\beta

or equivalently,

\operatorname{E}[lnX]=\psi(k)+ln\theta

where is the digamma function. Likewise,

\operatorname{var}[lnX]=\psi(1)(\alpha)=\psi(1)(k)

where

\psi(1)

is the trigamma function.

This can be derived using the exponential family formula for the moment generating function of the sufficient statistic, because one of the sufficient statistics of the gamma distribution is .

Information entropy

The information entropy is

\begin{align} \operatorname{H}(X)&=\operatorname{E}[-lnp(X)]\\[4pt] &=\operatorname{E}[-\alphaln\beta+ln\Gamma(\alpha)-(\alpha-1)lnX+\betaX]\\[4pt] &=\alpha-ln\beta+ln\Gamma(\alpha)+(1-\alpha)\psi(\alpha). \end{align}

In the, parameterization, the information entropy is given by

\operatorname{H}(X)=k+ln\theta+ln\Gamma(k)+(1-k)\psi(k).

Kullback–Leibler divergence

The Kullback–Leibler divergence (KL-divergence), of ("true" distribution) from ("approximating" distribution) is given by[14]

\begin{align} DKL(\alphap,\betap;\alphaq,\betaq)={}&(\alphap-\alphaq)\psi(\alphap)-log\Gamma(\alphap)+log\Gamma(\alphaq)\\ &{}+\alphaq(log\betap-log\betaq)+

\alpha
p\betaq-\betap
\betap

. \end{align}

Written using the, parameterization, the KL-divergence of from is given by

\begin{align} DKL(kp,\thetap;kq,\thetaq)={}&(kp-kq)\psi(kp)-log\Gamma(kp)+log\Gamma(kq)\\ &{}+kq(log\thetaq-log\thetap)+kp

\thetap-\thetaq
\thetaq

. \end{align}

Laplace transform

The Laplace transform of the gamma PDF is

F(s)=(1+\thetas)-k=

\beta\alpha
(s+\beta)\alpha

.

Related distributions

General

X1,X2,\ldots,Xn

be

n

independent and identically distributed random variables following an exponential distribution with rate parameter λ, then

\sumiXi

~ Gamma(n, λ) where n is the shape parameter and is the rate, and \bar = \frac \sum_i X_i \sim \operatorname(n, n * \lambda).

X\sim\Gamma(k\inZ,\theta),    Y\sim\operatorname{Pois}\left(

x
\theta

\right),

then

P(X>x)=P(Y<k).

X2\sim\Gamma\left(

3
2

,2a2\right).

\sqrt{X}

follows a generalized gamma distribution with parameters,, and

a=\sqrt{\theta}

.

Xq

for

q>0

follows a generalized gamma distribution with parameters,, and

a=\thetaq

.

Xk\sim\Gamma(\alphak,\thetak)

are independent, then
\alpha2\theta2X1
\alpha1\theta1X2

\simF(2\alpha1,2\alpha2)

, or equivalently,
X1
X2

\sim\beta'\left(\alpha1,\alpha2,1,

\theta1
\theta2

\right)

Xk\sim\Gamma(\alphak,\betak)

are independent, then
\alpha2\beta1X1
\alpha1\beta2X2

\simF(2\alpha1,2\alpha2)

, or equivalently,
X1
X2

\sim\beta'\left(\alpha1,\alpha2,1,

\beta2
\beta1

\right)

f(x\mid\alpha,\beta,\gamma)=

\alpha
2
2\betax\alpha-1\exp(-\betax2+\gammax)
\Psi{\left(\alpha,
\gamma
\sqrt{\beta
2

\right)}}

, where

\Psi(\alpha,z)={}1\Psi

1\left(\begin{matrix}\left(\alpha,1
2

\right)\\(1,0)\end{matrix};z\right)

denotes the Fox–Wright Psi function.

x|\theta\sim\Gamma(k,\theta)

, if the scale parameter

\theta\simIG(b,1)

where

IG

denotes the Inverse-gamma distribution, then the marginal distribution

x\sim\beta'(k,b)

where

\beta'

denotes the Beta prime distribution.

Compound gamma

If the shape parameter of the gamma distribution is known, but the inverse-scale parameter is unknown, then a gamma distribution for the inverse scale forms a conjugate prior. The compound distribution, which results from integrating out the inverse scale, has a closed-form solution known as the compound gamma distribution.[18]

If, instead, the shape parameter is known but the mean is unknown, with the prior of the mean being given by another gamma distribution, then it results in K-distribution.

Weibull and stable count

The gamma distribution

f(x;k)(k>1)

can be expressed as the product distribution of a Weibull distribution and a variant form of the stable count distribution.Its shape parameter

k

can be regarded as the inverse of Lévy's stability parameter in the stable count distribution: f(x;k) = \displaystyle\int_0^\infty \frac \, W_k\left(\frac\right) \left[k u^{k-1} \, \mathfrak{N}_{\frac{1}{k}}\left(u^k\right) \right] \, du,where

ak{N}\alpha(\nu)

is a standard stable count distribution of shape

\alpha=1/k

, and

Wk(x)

is a standard Weibull distribution of shape

k

.

Statistical inference

Parameter estimation

Maximum likelihood estimation

The likelihood function for iid observations is

L(k,\theta)=

N
\prod
i=1

f(xi;k,\theta)

from which we calculate the log-likelihood function

\ell(k,\theta)=(k-1)

N
\sum
i=1

lnxi-

N
\sum
i=1
xi
\theta

-Nkln\theta-Nln\Gamma(k)

\bar{x}

divided by the shape parameter :

\hat{\theta}=

1
kN
N
\sum
i=1

xi=

\bar{x
}

Substituting this into the log-likelihood function gives

\ell(k)=

N
(k-1)\sum
i=1

lnxi-Nk-Nkln\left(

\sumxi
kN

\right)-Nln\Gamma(k)

We need at least two samples:

N\ge2

, because for

N=1

, the function

\ell(k)

increases without bounds as

k\toinfty

. For

k>0

, it can be verified that

\ell(k)

is strictly concave, by using inequality properties of the polygamma function. Finding the maximum with respect to by taking the derivative and setting it equal to zero yields

lnk-\psi(k)=ln\left(

1
N
N
\sum
i=1

xi\right)-

1
N
N
\sum
i=1

lnxi=ln\bar{x}-\overline{lnx}

where is the digamma function and

\overline{lnx}

is the sample mean of . There is no closed-form solution for . The function is numerically very well behaved, so if a numerical solution is desired, it can be found using, for example, Newton's method. An initial value of can be found either using the method of moments, or using the approximation

lnk-\psi(k)

1
2k

\left(1+

1
6k+1

\right)

If we let

s=ln\left(

1
N
N
\sum
i=1

xi\right)-

1
N
N
\sum
i=1

lnxi=ln\bar{x}-\overline{lnx}

then is approximately

k

3-s+\sqrt{(s-3)2+24s
}

which is within 1.5% of the correct value.[19] An explicit form for the Newton–Raphson update of this initial guess is:[20]

k\leftarrowk-

lnk-\psi(k)-s
1
k
-\psi\prime(k)

.

At the maximum-likelihood estimate

(\hatk,\hat\theta)

, the expected values for and

lnx

agree with the empirical averages:

\begin{align} \hatk\hat\theta&=\barx&&and& \psi(\hatk)+ln\hat\theta&=\overline{lnx}. \end{align}

Caveat for small shape parameter

For data,

(x1,\ldots,xN)

, that is represented in a floating point format that underflows to 0 for values smaller than

\varepsilon

, the logarithms that are needed for the maximum-likelihood estimate will cause failure if there are any underflows. If we assume the data was generated by a gamma distribution with cdf

F(x;k,\theta)

, then the probability that there is at least one underflow is:

P(underflow)=1-(1-F(\varepsilon;k,\theta))N

This probability will approach 1 for small and large . For example, at

k=10-2

,

N=104

and

\varepsilon=2.25 x 10-308

,

P(underflow)0.9998

. A workaround is to instead have the data in logarithmic format.

In order to test an implementation of a maximum-likelihood estimator that takes logarithmic data as input, it is useful to be able to generate non-underflowing logarithms of random gamma variates, when

k<1

. Following the implementation in scipy.stats.loggamma, this can be done as follows: sample

Y\simGamma(k+1,\theta)

and

U\simUniform

independently. Then the required logarithmic sample is

Z=ln(Y)+ln(U)/k

, so that

\exp(Z)\simGamma(k,\theta)

.

Closed-form estimators

There exist consistent closed-form estimators of and that are derived from the likelihood of the generalized gamma distribution.[21]

The estimate for the shape is

\hat{k}=

N
N
\sum
i=1
xi
N
N
\sum
i=1
xilnxi-
N
\sum
i=1
xi
N
\sum
i=1
lnxi

and the estimate for the scale is

\hat{\theta}=

1
N2

\left(N

N
\sum
i=1

xilnxi-

N
\sum
i=1

xi

N
\sum
i=1

lnxi\right)

Using the sample mean of, the sample mean of, and the sample mean of the product simplifies the expressions to:

\hat{k}=\bar{x}/\hat{\theta}

\hat{\theta}=\overline{xln{x}}-\bar{x}\overline{ln{x}}.

If the rate parameterization is used, the estimate of

\hat{\beta}=1/\hat{\theta}

.

These estimators are not strictly maximum likelihood estimators, but are instead referred to as mixed type log-moment estimators. They have however similar efficiency as the maximum likelihood estimators.

Although these estimators are consistent, they have a small bias. A bias-corrected variant of the estimator for the scale is

\tilde{\theta}=

N
N-1

\hat{\theta}

A bias correction for the shape parameter is given as[22]

\tilde{k}=\hat{k}-

1
N

\left(3\hat{k}-

2\left(
3
\hat{k
}\right) - \frac \frac \right)

Bayesian minimum mean squared error

With known and unknown, the posterior density function for theta (using the standard scale-invariant prior for) is

P(\theta\midk,x1,...,xN)\propto

1
\theta
N
\prod
i=1

f(xi;k,\theta)

Denoting

y\equiv

Nx
\sum
i

,    P(\theta\midk,x1,...,xN)=C(xi)\theta-Ne-y/\theta

Integration with respect to can be carried out using a change of variables, revealing that is gamma-distributed with parameters, .

infty
\int
0

\theta-Nke-y/\thetad\theta=

infty
\int
0

xNke-xydx=y-(Nk\Gamma(Nk-m)

The moments can be computed by taking the ratio (by)

\operatorname{E}[xm]=

\Gamma(Nk-m)
\Gamma(Nk)

ym

which shows that the mean ± standard deviation estimate of the posterior distribution for is

y
Nk-1

\pm\sqrt{

y2
(Nk-1)2(Nk-2)
}.

Bayesian inference

Conjugate prior

In Bayesian inference, the gamma distribution is the conjugate prior to many likelihood distributions: the Poisson, exponential, normal (with known mean), Pareto, gamma with known shape, inverse gamma with known shape parameter, and Gompertz with known scale parameter.

The gamma distribution's conjugate prior is:[23]

p(k,\theta\midp,q,r,s)=

1
Z
k-1
p
-\theta-1q
e
\Gamma(k)r\thetak

,

where is the normalizing constant with no closed-form solution.The posterior distribution can be found by updating the parameters as follows:

\begin{align} p'&=p\prod\nolimitsixi,\\ q'&=q+\sum\nolimitsixi,\\ r'&=r+n,\\ s'&=s+n, \end{align}

where is the number of observations, and is the -th observation.

Occurrence and applications

Consider a sequence of events, with the waiting time for each event being an exponential distribution with rate . Then the waiting time for the -th event to occur is the gamma distribution with integer shape

\alpha=n

. This construction of the gamma distribution allows it to model a wide variety of phenomena where several sub-events, each taking time with exponential distribution, must happen in sequence for a major event to occur.[24] Examples include the waiting time of cell-division events,[25] number of compensatory mutations for a given mutation,[26] waiting time until a repair is necessary for a hydraulic system,[27] and so on.

In biophysics, the dwell time between steps of a molecular motor like ATP synthase is nearly exponential at constant ATP concentration, revealing that each step of the motor takes a single ATP hydrolysis. If there were n ATP hydrolysis events, then it would be a gamma distribution with degree n.[28]

The gamma distribution has been used to model the size of insurance claims[29] and rainfalls.[30] This means that aggregate insurance claims and the amount of rainfall accumulated in a reservoir are modelled by a gamma process – much like the exponential distribution generates a Poisson process.

The gamma distribution is also used to model errors in multi-level Poisson regression models because a mixture of Poisson distributions with gamma-distributed rates has a known closed form distribution, called negative binomial.

In wireless communication, the gamma distribution is used to model the multi-path fading of signal power; see also Rayleigh distribution and Rician distribution.

In oncology, the age distribution of cancer incidence often follows the gamma distribution, wherein the shape and scale parameters predict, respectively, the number of driver events and the time interval between them.[31] [32]

In neuroscience, the gamma distribution is often used to describe the distribution of inter-spike intervals.[33] [34]

In bacterial gene expression, the copy number of a constitutively expressed protein often follows the gamma distribution, where the scale and shape parameter are, respectively, the mean number of bursts per cell cycle and the mean number of protein molecules produced by a single mRNA during its lifetime.[35]

In genomics, the gamma distribution was applied in peak calling step (i.e., in recognition of signal) in ChIP-chip[36] and ChIP-seq[37] data analysis.

In Bayesian statistics, the gamma distribution is widely used as a conjugate prior. It is the conjugate prior for the precision (i.e. inverse of the variance) of a normal distribution. It is also the conjugate prior for the exponential distribution.

In phylogenetics, the gamma distribution is the most commonly used approach to model among-sites rate variation[38] when maximum likelihood, Bayesian, or distance matrix methods are used to estimate phylogenetic trees. Phylogenetic analyzes that use the gamma distribution to model rate variation estimate a single parameter from the data because they limit consideration to distributions where . This parameterization means that the mean of this distribution is 1 and the variance is . Maximum likelihood and Bayesian methods typically use a discrete approximation to the continuous gamma distribution.[39] [40]

Random variate generation

Given the scaling property above, it is enough to generate gamma variables with, as we can later convert to any value of with a simple division.

Suppose we wish to generate random variables from, where n is a non-negative integer and . Using the fact that a distribution is the same as an distribution, and noting the method of generating exponential variables, we conclude that if is uniformly distributed on (0, 1], then is distributed (i.e. inverse transform sampling). Now, using the "-addition" property of gamma distribution, we expand this result:

n
-\sum
k=1

lnUk\sim\Gamma(n,1)

where are all uniformly distributed on (0, 1] and independent. All that is left now is to generate a variable distributed as for and apply the "-addition" property once more. This is the most difficult part.

Random generation of gamma variates is discussed in detail by Devroye,[41] noting that none are uniformly fast for all shape parameters. For small values of the shape parameter, the algorithms are often not valid. For arbitrary values of the shape parameter, one can apply the Ahrens and Dieter[42] modified acceptance-rejection method Algorithm GD (shape), or transformation method[43] when . Also see Cheng and Feast Algorithm GKM 3[44] or Marsaglia's squeeze method.[45]

The following is a version of the Ahrens-Dieter acceptance–rejection method:[42]

  1. Generate, and as iid uniform (0, 1] variates.
  2. If
U\lee
e+\delta
then

\xi=V1/\delta

and

η=W\xi\delta-1

. Otherwise,

\xi=1-lnV

and

η=We-\xi

.
  1. If

η>\xi\delta-1e-\xi

then go to step 1.
  1. is distributed as .

A summary of this is

\theta\left(\xi-

\lfloork\rfloor
\sum
i=1

lnUi\right)\sim\Gamma(k,\theta)

where

\scriptstyle\lfloork\rfloor

is the integer part of, is generated via the algorithm above with (the fractional part of) and the are all independent.

While the above approach is technically correct, Devroye notes that it is linear in the value of and generally is not a good choice. Instead, he recommends using either rejection-based or table-based methods, depending on context.[41]

For example, Marsaglia's simple transformation-rejection method relying on one normal variate and one uniform variate :[46]

  1. Set

d=a-

13
and

c=

1{\sqrt{9d}}
.
  1. Set

v=(1+cX)3

.
  1. If

v>0

and

lnU<

X2
2

+d-dv+dlnv

return

dv

, else go back to step 2.

With

1\lea=\alpha=k

generates a gamma distributed random number in time that is approximately constant with . The acceptance rate does depend on, with an acceptance rate of 0.95, 0.98, and 0.99 for k=1, 2, and 4. For, one can use

\gamma\alpha=\gamma1+\alphaU1/\alpha

to boost to be usable with this method.

In Matlab numbers can be generated using the function gamrnd, which uses the k, θ representation.

External links

Notes and References

  1. Park . Sung Y. . Bera . Anil K. . 2009 . Maximum entropy autoregressive conditional heteroskedasticity model . Journal of Econometrics . 150 . 2 . 219–230 . 2011-06-02 . 10.1016/j.jeconom.2008.12.014 . 10.1.1.511.9750 . https://web.archive.org/web/20160307144515/http://wise.xmu.edu.cn/uploadfiles/paper-masterdownload/2009519932327055475115776.pdf . 2016-03-07 . dead .
  2. Book: Robert V. Hogg . R. V. . Hogg . A. T. . Craig . 1978 . Introduction to Mathematical Statistics . 4th . New York . Macmillan . 0023557109. Remark 3.3.1.
  3. 1311.1704 . cs.IR . Prem . Gopalan . Jake M. . Hofman . Scalable Recommendation with Poisson Factorization . Blei . David M. . 2013 . David Blei.
  4. Papoulis, Pillai, Probability, Random Variables, and Stochastic Processes, Fourth Edition
  5. Jeesen Chen, Herman Rubin, Bounds for the difference between median and mean of gamma and Poisson distributions, Statistics & Probability Letters, Volume 4, Issue 6, October 1986, Pages 281–283,, https://dx.doi.org/10.1016/0167-7152(86)90044-1.
  6. Choi, K. P. "On the Medians of the Gamma Distributions and an Equation of Ramanujan", Proceedings of the American Mathematical Society, Vol. 121, No. 1 (May, 1994), pp. 245–251.
  7. Berg, Christian . Pedersen, Henrik L. . amp. The Chen–Rubin conjecture in a continuous setting . Methods and Applications of Analysis . March 2006 . 13 . 1 . 63–88 . 10.4310/MAA.2006.v13.n1.a4 . 6704865 . 1 April 2020. free .
  8. Berg, Christian and Pedersen, Henrik L. "Convexity of the median in the gamma distribution".
  9. Gaunt, Robert E., and Milan Merkle . On bounds for the mode and median of the generalized hyperbolic and related distributions . Journal of Mathematical Analysis and Applications . 2021 . 493 . 1 . 124508. 10.1016/j.jmaa.2020.124508 . 2002.01884 . 221103640 .
  10. Lyon . Richard F. . On closed-form tight bounds and approximations for the median of a gamma distribution . . 13 May 2021 . 16 . 5 . e0251626 . 10.1371/journal.pone.0251626 . 33984053 . 8118309 . 2011.04060 . 2021PLoSO..1651626L . free .
  11. Lyon . Richard F. . Tight bounds for the median of a gamma distribution . . 13 May 2021 . 18 . 9 . e0288601 . 10.1371/journal.pone.0288601 . 37682854 . 10490949 . free .
  12. Mathai. A. M.. Storage capacity of a dam with gamma type inputs. Annals of the Institute of Statistical Mathematics. en. 34. 3. 591–597. 10.1007/BF02481056. 0020-3157. 1982. 122537756.
  13. P. G. . Moschopoulos . 1985 . The distribution of the sum of independent gamma random variables . Annals of the Institute of Statistical Mathematics . 37 . 3 . 541–544 . 10.1007/BF02481123 . 120066454 .
  14. Web site: W. D.. Penny. KL-Divergences of Normal, Gamma, Dirichlet, and Wishart densities.
  15. Web site: ExpGammaDistribution—Wolfram Language Documentation.
  16. Web site: scipy.stats.loggamma — SciPy v1.8.0 Manual. docs.scipy.org.
  17. Sun . Jingchao . Kong . Maiying . Pal . Subhadip . The Modified-Half-Normal distribution: Properties and an efficient sampling scheme . Communications in Statistics - Theory and Methods . 22 June 2021 . 52 . 5 . 1591–1613 . 10.1080/03610926.2021.1934700 . 237919587 . 0361-0926.
  18. Dubey. Satya D. . Compound gamma, beta and F distributions. Metrika. December 1970. 16. 27–31 . 10.1007/BF02613934. 123366328 .
  19. Web site: Minka . Thomas P. . 2002 . Estimating a Gamma distribution .
  20. Choi . S. C. . Wette . R. . 1969 . Maximum Likelihood Estimation of the Parameters of the Gamma Distribution and Their Bias . Technometrics . 11 . 4 . 683–690 . 10.1080/00401706.1969.10490731 .
  21. Closed-Form Estimators for the Gamma Distribution Derived from Likelihood Equations . 10.1080/00031305.2016.1209129 . 2017 . Ye . Zhi-Sheng . Chen . Nan . The American Statistician . 71 . 2 . 177–181 . 124682698 .
  22. A Note on Bias of Closed-Form Estimators for the Gamma Distribution Derived from Likelihood Equations . 10.1080/00031305.2018.1513376 . 2019 . Louzada . Francisco . Ramos . Pedro L. . Ramos . Eduardo . The American Statistician . 73 . 2 . 195–199 . 126086375 .
  23. Fink, D. 1995 A Compendium of Conjugate Priors. In progress report: Extension and enhancement of methods for setting data quality objectives. (DOE contract 95‑831).
  24. Book: Jessica., Scheiner, Samuel M., 1956- Gurevitch . Design and analysis of ecological experiments . 2001 . Oxford University Press . 0-19-513187-8 . 13. Failure-time analysis . 43694448 . https://books.google.com/books?id=AgsTDAAAQBAJ&dq=gamma+distribution+failure+waiting+time&pg=PA235.
  25. Golubev . A. . March 2016 . Applications and implications of the exponentially modified gamma distribution as a model for time variabilities related to cell proliferation and gene expression . Journal of Theoretical Biology . 393 . 203–217 . 10.1016/j.jtbi.2015.12.027 . 26780652 . 2016JThBi.393..203G . 0022-5193.
  26. Poon . Art . Davis . Bradley H . Chao . Lin . 2005-07-01 . The Coupon Collector and the Suppressor Mutation . Genetics . 170 . 3 . 1323–1332 . 10.1534/genetics.104.037259 . 15879511 . 1451182 . 1943-2631.
  27. Vineyard . Michael . Amoako-Gyampah . Kwasi . Meredith . Jack R . July 1999 . Failure rate distributions for flexible manufacturing systems: An empirical study . European Journal of Operational Research . 116 . 1 . 139–155 . 10.1016/s0377-2217(98)00096-4 . 0377-2217.
  28. Rief . Matthias . Rock . Ronald S. . Mehta . Amit D. . Mooseker . Mark S. . Cheney . Richard E. . Spudich . James A. . 2000-08-15 . Myosin-V stepping kinetics: A molecular model for processivity . Proceedings of the National Academy of Sciences . en . 97 . 17 . 9482–9486 . 10.1073/pnas.97.17.9482 . 0027-8424 . 16890 . 10944217 . free . 2000PNAS...97.9482R .
  29. p. 43, Philip J. Boland, Statistical and Probabilistic Methods in Actuarial Science, Chapman & Hall CRC 2007
  30. Wilks . Daniel S. . 1990 . Maximum Likelihood Estimation for the Gamma Distribution Using Data Containing Zeros . Journal of Climate . 3 . 12 . 1495–1501 . 10.1175/1520-0442(1990)003<1495:MLEFTG>2.0.CO;2 . 26196366 . 1990JCli....3.1495W . 0894-8755. free .
  31. Belikov . Aleksey V. . The number of key carcinogenic events can be predicted from cancer incidence . Scientific Reports . 22 September 2017 . 7 . 1 . 12170 . 10.1038/s41598-017-12448-7. 28939880 . 5610194 . 2017NatSR...712170B .
  32. Belikov. Aleksey V.. Vyatkin. Alexey. Leonov. Sergey V.. 2021-08-06. The Erlang distribution approximates the age distribution of incidence of childhood and young adulthood cancers. PeerJ. en. 9. e11976. 10.7717/peerj.11976. 34434669. 8351573. 2167-8359. free.
  33. J. G. Robson and J. B. Troy, "Nature of the maintained discharge of Q, X, and Y retinal ganglion cells of the cat", J. Opt. Soc. Am. A 4, 2301–2307 (1987)
  34. M.C.M. Wright, I.M. Winter, J.J. Forster, S. Bleeck "Response to best-frequency tone bursts in the ventral cochlear nucleus is governed by ordered inter-spike interval statistics", Hearing Research 317 (2014)
  35. N. Friedman, L. Cai and X. S. Xie (2006) "Linking stochastic dynamics to population distribution: An analytical framework of gene expression", Phys. Rev. Lett. 97, 168302.
  36. DJ Reiss, MT Facciotti and NS Baliga (2008) "Model-based deconvolution of genome-wide DNA binding", Bioinformatics, 24, 396–403
  37. MA Mendoza-Parra, M Nowicka, W Van Gool, H Gronemeyer (2013) "Characterising ChIP-seq binding patterns by model-based peak shape deconvolution", BMC Genomics, 14:834
  38. Yang . Ziheng . September 1996 . Among-site rate variation and its impact on phylogenetic analyses . Trends in Ecology & Evolution . en . 11 . 9 . 367–372 . 10.1016/0169-5347(96)10041-0. 21237881 . 1996TEcoE..11..367Y .
  39. Yang . Ziheng . September 1994 . Maximum likelihood phylogenetic estimation from DNA sequences with variable rates over sites: Approximate methods . Journal of Molecular Evolution . en . 39 . 3 . 306–314 . 10.1007/BF00160154 . 7932792 . 1994JMolE..39..306Y . 17911050 . 0022-2844.
  40. Felsenstein . Joseph . 2001-10-01 . Taking Variation of Evolutionary Rates Between Sites into Account in Inferring Phylogenies . Journal of Molecular Evolution . 53 . 4–5 . 447–455 . 10.1007/s002390010234 . 11675604 . 2001JMolE..53..447F . 9791493 . 0022-2844.
  41. Book: Devroye, Luc . Springer-Verlag . New York. 1986 . Non-Uniform Random Variate Generation . 978-0-387-96305-1. See Chapter 9, Section 3.
  42. Ahrens . J. H. . Dieter . U . January 1982 . Generating gamma variates by a modified rejection technique . Communications of the ACM . 25 . 1 . 47–54 . 10.1145/358315.358390. 15128188 . free . . See Algorithm GD, p. 53.
  43. Ahrens . J. H. . Dieter . U. . 1974 . Computer methods for sampling from gamma, beta, Poisson and binomial distributions . Computing . 12 . 3 . 223–246 . 10.1.1.93.3828 . 10.1007/BF02293108. 37484126 .
  44. Some Simple Gamma Variate Generators . 2347200 . Cheng . R. C. H. . Feast . G. M. . Journal of the Royal Statistical Society. Series C (Applied Statistics) . 1979 . 28 . 3 . 290–295 . 10.2307/2347200 .
  45. Marsaglia, G. The squeeze method for generating gamma variates. Comput, Math. Appl. 3 (1977), 321–325.
  46. Marsaglia. G. . Tsang . W. W. . 2000 . A simple method for generating gamma variables. ACM Transactions on Mathematical Software. 26 . 3 . 363–372 . 10.1145/358407.358414. 2634158 .