Английская Википедия:Gamma distribution

Материал из Онлайн справочника
Перейти к навигацииПерейти к поиску

Шаблон:Short description Шаблон:Infobox probability distribution 2</math> | kurtosis = <math>\frac{6}{k}</math> | entropy = <math>\begin{align}

                     k &+ \ln\theta + \ln\Gamma(k)\\
                       &+ (1 - k)\psi(k)
                   \end{align}</math>

| mgf = <math>(1 - \theta t)^{-k} \text{ for } t < \frac{1}{\theta}</math> | char = <math>(1 - \theta it)^{-k}</math> | parameters2 = Шаблон:Bulleted list | support2 = <math>x \in (0, \infty)</math> | pdf2 = <math>f(x)=\frac{\beta^\alpha}{\Gamma(\alpha)} x^{\alpha - 1} e^{-\beta x }</math> | cdf2 = <math>F(x)=\frac{1}{\Gamma(\alpha)} \gamma(\alpha, \beta x)</math> | mean2 = <math>\frac{\alpha}{\beta}</math> | median2 = No simple closed form | mode2 = <math>\frac{\alpha - 1}{\beta} \text{ for } \alpha \geq 1\text{, }0 \text{ for } \alpha < 1</math> | variance2 = <math>\frac{\alpha}{\beta^2}</math> | skewness2 = <math>\frac{2}{\sqrt{\alpha}}</math> | kurtosis2 = <math>\frac{6}{\alpha}</math> | entropy2 = <math>\begin{align}

                     \alpha &- \ln \beta + \ln\Gamma(\alpha)\\
                            &+ (1 - \alpha)\psi(\alpha)
                   \end{align}</math>

| mgf2 = <math>\left(1 - \frac{t}{\beta}\right)^{-\alpha} \text{ for } t < \beta</math> | char2 = <math>\left(1 - \frac{it}{\beta}\right)^{-\alpha}</math> | moments = <math> k = \frac{E[X]^2}{V[X]} \quad \quad</math> <math> \theta = \frac{V[X]}{E[X]} \quad \quad</math> | moments2 = <math> \alpha = \frac{E[X]^2}{V[X]} </math> <math>\beta = \frac{E[X]}{V[X]} </math> | fisher = <math>I(k, \theta) = \begin{pmatrix}\psi^{(1)}(k) & \theta^{-1} \\ \theta^{-1} & k \theta^{-2}\end{pmatrix}</math> | fisher2 = <math>I(\alpha, \beta) = \begin{pmatrix}\psi^{(1)}(\alpha) & -\beta^{-1} \\ -\beta^{-1} & \alpha \beta^{-2}\end{pmatrix}</math> }}

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 Шаблон:Mvar and a scale parameter Шаблон:Mvar
  2. With a shape parameter <math>\alpha = k</math> and an inverse scale parameter <math>\beta = 1/ \theta</math> , called a rate parameter.

In each of these forms, both parameters are positive real numbers.

The distribution has significant applications across 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 <math>1/x</math> base measure) for a random variable Шаблон:Mvar for which Шаблон:Math is fixed and greater than zero, and Шаблон:Math is fixed (Шаблон:Mvar is the digamma function).[1]

Definitions

The parameterization with Шаблон:Mvar and Шаблон:Mvar 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 Шаблон:Mvar and Шаблон:Mvar 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 Шаблон:Mvar of an exponential distribution or a Poisson distribution[3] – or for that matter, the Шаблон:Mvar 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 Шаблон:Mvar is a positive integer, then the distribution represents an Erlang distribution; i.e., the sum of Шаблон:Mvar independent exponentially distributed random variables, each of which has a mean of Шаблон:Mvar.

Characterization using shape α and rate β

The gamma distribution can be parameterized in terms of a shape parameter Шаблон:Math and an inverse scale parameter Шаблон:Math, called a rate parameter. A random variable Шаблон:Mvar that is gamma-distributed with shape Шаблон:Mvar and rate Шаблон:Mvar is denoted

<math>X \sim \Gamma(\alpha, \beta) \equiv \operatorname{Gamma}(\alpha,\beta)</math>

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

<math>

\begin{align} f(x;\alpha,\beta) & = \frac{ x^{\alpha-1} e^{-\beta x} \beta^\alpha}{\Gamma(\alpha)} \quad \text{ for } x > 0 \quad \alpha, \beta > 0, \\[6pt] \end{align} </math>

where <math>\Gamma(\alpha)</math> is the gamma function. For all positive integers, <math>\Gamma(\alpha)=(\alpha-1)!</math>.

The cumulative distribution function is the regularized gamma function:

<math> F(x;\alpha,\beta) = \int_0^x f(u;\alpha,\beta)\,du= \frac{\gamma(\alpha, \beta x)}{\Gamma(\alpha)},</math>

where <math>\gamma(\alpha, \beta x)</math> is the lower incomplete gamma function.

If Шаблон:Mvar is a positive integer (i.e., the distribution is an Erlang distribution), the cumulative distribution function has the following series expansion:[4]

<math>F(x;\alpha,\beta) = 1-\sum_{i=0}^{\alpha-1} \frac{(\beta x)^i}{i!} e^{-\beta x} = e^{-\beta x} \sum_{i=\alpha}^{\infty} \frac{(\beta x)^i}{i!}.</math>

Characterization using shape k and scale θ

A random variable Шаблон:Mvar that is gamma-distributed with shape Шаблон:Mvar and scale Шаблон:Mvar is denoted by

<math>X \sim \Gamma(k, \theta) \equiv \operatorname{Gamma}(k, \theta)</math>
Файл:Gamma-PDF-3D.png
Illustration of the gamma PDF for parameter values over Шаблон:Mvar and Шаблон:Mvar with Шаблон:Mvar set to Шаблон:Math and Шаблон:Math. One can see each Шаблон:Mvar layer by itself here [1] as well as by Шаблон:Mvar [2] and Шаблон:Mvar. [3].

The probability density function using the shape-scale parametrization is

<math>f(x;k,\theta) = \frac{x^{k-1}e^{-x/\theta}}{\theta^k\Gamma(k)} \quad \text{ for } x > 0 \text{ and } k, \theta > 0.</math>

Here Шаблон:Math is the gamma function evaluated at Шаблон:Mvar.

The cumulative distribution function is the regularized gamma function:

<math> F(x;k,\theta) = \int_0^x f(u;k,\theta)\,du = \frac{\gamma\left(k, \frac{x}{\theta}\right)}{\Gamma(k)},</math>

where <math>\gamma\left(k, \frac{x}{\theta}\right)</math> is the lower incomplete gamma function.

It can also be expressed as follows, if Шаблон:Mvar is a positive integer (i.e., the distribution is an Erlang distribution):[4]

<math>F(x;k,\theta) = 1-\sum_{i=0}^{k-1} \frac{1}{i!} \left(\frac{x}{\theta} \right)^i e^{-x/\theta} = e^{-x/\theta} \sum_{i=k}^\infty \frac{1}{i!} \left( \frac{x}{\theta} \right)^i.</math>

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:

<math>\mu = k\theta = \alpha/\beta</math>

The variance is:

<math>\sigma^2 = k \theta^2 = \alpha/\beta^2</math>

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

<math>\sigma/\mu = k^{-0.5} = 1/\sqrt{\alpha}</math>

Skewness

The skewness of the gamma distribution only depends on its shape parameter, Шаблон:Mvar, and it is equal to <math>2/\sqrt{k}.</math>

Higher moments

The Шаблон:Mvar-th raw moment is given by:

<math>

\mathrm{E}[X^n] = \theta^n \frac{\Gamma(k+n)}{\Gamma(k)} = \theta^n \prod_{i=1}^n(k+i-1) \; \text{ for } n=1, 2, \ldots. </math>

Median approximations and bounds

Файл:Gamma distribution median bounds.png
Bounds and asymptotic approximations to the median of the gamma distribution. The cyan-colored region indicates the large gap between published lower and upper 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 Шаблон:Mvar such that

<math>\frac{1}{\Gamma(k) \theta^k} \int_0^{\nu} x^{k - 1} e^{-x/\theta} dx = \frac{1}{2}.</math>

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 <math>\theta = 1</math>)

<math> k - \frac{1}{3} < \nu(k) < k, </math>

where <math>\mu(k) = k</math> is the mean and <math>\nu(k)</math> is the median of the <math>\text{Gamma}(k,1)</math> distribution.[5] For other values of the scale parameter, the mean scales to <math>\mu = k\theta</math>, and the median bounds and approximations would be similarly scaled by Шаблон:Mvar.

K. P. Choi found the first five terms in a Laurent series asymptotic approximation of the median by comparing the median to Ramanujan's <math> \theta </math> function.[6] Berg and Pedersen found more terms:[7]

<math> \nu(k) = k - \frac{1}{3} + \frac{8}{405 k} + \frac{184}{25515 k^2} + \frac{2248}{3444525 k^3} - \frac{19006408}{15345358875 k^4} - O\left(\frac{1}{k^5}\right) + \cdots </math>
Файл:Gamma distribution median Lyon bounds.png
Two gamma distribution median asymptotes which were proved in 2023 to be bounds (upper solid red and lower dashed red), of the from <math>\nu(k) \approx 2^{-1/k}(A + k)</math>, and an interpolation between them that makes an approximation (dotted red) that is exact at k = 1 and has maximum relative error of about 0.6%. The cyan shaded region is the remaining gap between upper and lower bounds (or conjectured bounds), including these new bounds and the bounds in the previous figure.
Файл:Gamma distribution median loglog bounds.png
Log–log plot of upper (solid) and lower (dashed) bounds to the median of a gamma distribution and the gaps between them. The green, yellow, and cyan regions represent the gap before the Lyon 2021 paper. The green and yellow narrow that gap with the lower bounds that Lyon proved. Lyon's conjectured bounds further narrow the yellow. Mostly within the yellow, closed-form rational-function-interpolated bounds are plotted along with the numerically calculated median (dotted) value. Tighter interpolated bounds exist but are not plotted, as they would not be resolved at this scale.

Partial sums of these series are good approximations for high enough Шаблон:Mvar; they are not plotted in the figure, which is focused on the low-Шаблон:Mvar region that is less well approximated.

Berg and Pedersen also proved many properties of the median, showing that it is a convex function of Шаблон:Mvar,[8] and that the asymptotic behavior near <math>k = 0</math> is <math>\nu(k) \approx e^{-\gamma}2^{-1/k}</math> (where Шаблон:Mvar is the Euler–Mascheroni constant), and that for all <math>k > 0</math> the median is bounded by <math>k 2^{-1/k} < \nu(k) < k e^{-1/3k}</math>.[7]

A closer linear upper bound, for <math>k \ge 1</math> only, was provided in 2021 by Gaunt and Merkle,[9] relying on the Berg and Pedersen result that the slope of <math>\nu(k)</math> is everywhere less than 1:

<math> \nu(k) \le k - 1 + \log2 ~~</math> for <math>k \ge 1</math> (with equality at <math>k = 1</math>)

which can be extended to a bound for all <math>k > 0</math> 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 Шаблон:Mvar and reasonable down to <math>k = 0.5</math> or a bit lower follows from the Wilson–Hilferty transformation:

<math> \nu(k) = k \left( 1 - \frac{1}{9k} \right)^3 </math>

which goes negative for <math>k < 1/9</math>.

In 2021, Lyon proposed several approximations of the form <math>\nu(k) \approx 2^{-1/k}(A + Bk)</math>. He conjectured values of Шаблон:Mvar and Шаблон:Mvar for which this approximation is an asymptotically tight upper or lower bound for all <math>k > 0</math>.[10] In particular, he proposed these closed-form bounds, which he proved in 2023:[11]

<math> \nu_{L\infty}(k) = 2^{-1/k}(\log 2 - \frac{1}{3} + k) \quad</math> is a lower bound, asymptotically tight as <math>k \to \infty</math>
<math> \nu_U(k) = 2^{-1/k}(e^{-\gamma} + k) \quad</math> is an upper bound, asymptotically tight as <math>k \to 0</math>

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 <math>e^{-x}</math>:

<math>\nu(k) > \left( \frac{2}{\Gamma(k+1)} \right)^{-1/k} \quad</math> (approaching equality as <math>k \to 0</math>)

and the tangent line at <math>k = 1</math> where the derivative was found to be <math>\nu^\prime(1) \approx 0.9680448</math>:

<math>\nu(k) \ge \nu(1) + (k-1) \nu^\prime(1) \quad</math> (with equality at <math>k = 1</math>)
<math>\nu(k) \ge \log 2 + (k-1) (\gamma - 2 \operatorname{Ei}(-\log 2) - \log \log 2)</math>

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 <math>k = 1</math> (where <math>\nu(1) = \log 2</math>) and has a maximum relative error less than 0.6%. Interpolated approximations and bounds are all of the form

<math>\nu(k) \approx \tilde{g}(k)\nu_{L\infty}(k) + (1 - \tilde{g}(k))\nu_U(k)</math>

where <math>\tilde{g}</math> is an interpolating function running monotonically from 0 at low Шаблон:Mvar to 1 at high Шаблон:Mvar, approximating an ideal, or exact, interpolator <math>g(k)</math>:

<math>g(k) = \frac{\nu_U(k) - \nu(k)}{\nu_U(k) - \nu_{L\infty}(k)}</math>

For the simplest interpolating function considered, a first-order rational function

<math>\tilde{g}_1(k) = \frac{k}{b_0 + k}</math>

the tightest lower bound has

<math>b_0 = \frac{\frac{8}{405} + e^{-\gamma} \log 2 - \frac{\log^2 2}{2}}{e^{-\gamma} - \log 2 + \frac{1}{3}} - \log 2 \approx 0.143472</math>

and the tightest upper bound has

<math>b_0 = \frac{e^{-\gamma} - \log 2 + \frac{1}{3}}{1 - \frac{e^{-\gamma} \pi^2}{12}} \approx 0.374654</math>

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 Шаблон:Math has a Шаблон:Math distribution for Шаблон:Math (i.e., all distributions have the same scale parameter Шаблон:Mvar), then

<math> \sum_{i=1}^N X_i \sim\mathrm{Gamma} \left( \sum_{i=1}^N k_i, \theta \right)</math>

provided all Шаблон:Math are independent.

For the cases where the Шаблон:Math are independent but have different scale parameters, see Mathai [12] or Moschopoulos.[13]

The gamma distribution exhibits infinite divisibility.

Scaling

If

<math>X \sim \mathrm{Gamma}(k, \theta),</math>

then, for any Шаблон:Math,

<math>cX \sim \mathrm{Gamma}(k, c\,\theta),</math> by moment generating functions,

or equivalently, if

<math>X \sim \mathrm{Gamma}\left( \alpha,\beta \right)</math> (shape-rate parameterization)
<math>cX \sim \mathrm{Gamma}\left( \alpha, \frac \beta c \right),</math>

Indeed, we know that if Шаблон:Mvar is an exponential r.v. with rate Шаблон:Mvar, then Шаблон:Math is an exponential r.v. with rate Шаблон:Math; 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 Шаблон:Mvar divides the rate (or, equivalently, multiplies the scale).

Exponential family

The gamma distribution is a two-parameter exponential family with natural parameters Шаблон:Math and Шаблон:Math (equivalently, Шаблон:Math and Шаблон:Math), and natural statistics Шаблон:Mvar and Шаблон:Math.

If the shape parameter Шаблон:Mvar is held fixed, the resulting one-parameter family of distributions is a natural exponential family.

Logarithmic expectation and variance

One can show that

<math>\operatorname{E}[\ln X] = \psi(\alpha) - \ln \beta</math>

or equivalently,

<math>\operatorname{E}[\ln X] = \psi(k) + \ln \theta</math>

where Шаблон:Mvar is the digamma function. Likewise,

<math>\operatorname{var}[\ln X] = \psi^{(1)}(\alpha) = \psi^{(1)}(k)</math>

where <math>\psi^{(1)}</math> 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 Шаблон:Math.

Information entropy

The information entropy is

<math>

\begin{align} \operatorname{H}(X) & = \operatorname{E}[-\ln p(X)] \\[4pt] & = \operatorname{E}[-\alpha \ln \beta + \ln \Gamma(\alpha) - (\alpha-1)\ln X + \beta X] \\[4pt] & = \alpha - \ln \beta + \ln \Gamma(\alpha) + (1-\alpha)\psi(\alpha). \end{align} </math>

In the Шаблон:Mvar, Шаблон:Mvar parameterization, the information entropy is given by

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

Kullback–Leibler divergence

Файл:Gamma-KL-3D.png
Illustration of the Kullback–Leibler (KL) divergence for two gamma PDFs. Here Шаблон:Math which are set to Шаблон:Math and Шаблон:Math. The typical asymmetry for the KL divergence is clearly visible.

The Kullback–Leibler divergence (KL-divergence), of Шаблон:Math ("true" distribution) from Шаблон:Math ("approximating" distribution) is given by[14]

<math>

\begin{align} D_{\mathrm{KL}}(\alpha_p,\beta_p; \alpha_q, \beta_q) = {} & (\alpha_p-\alpha_q) \psi(\alpha_p) - \log\Gamma(\alpha_p) + \log\Gamma(\alpha_q) \\ & {} + \alpha_q(\log \beta_p - \log \beta_q) + \alpha_p\frac{\beta_q-\beta_p}{\beta_p}. \end{align} </math>

Written using the Шаблон:Mvar, Шаблон:Mvar parameterization, the KL-divergence of Шаблон:Math from Шаблон:Math is given by

<math>

\begin{align} D_{\mathrm{KL}}(k_p,\theta_p; k_q, \theta_q) = {} & (k_p-k_q)\psi(k_p) - \log\Gamma(k_p) + \log\Gamma(k_q) \\ & {} + k_q(\log \theta_q - \log \theta_p) + k_p \frac{\theta_p - \theta_q}{\theta_q}. \end{align} </math>

Laplace transform

The Laplace transform of the gamma PDF is

<math>F(s) = (1 + \theta s)^{-k} = \frac{\beta^\alpha}{(s + \beta)^\alpha} .</math>

Related distributions

General

<math>X \sim \Gamma(k \in \mathbf{Z}, \theta), \qquad Y \sim \operatorname{Pois}\left(\frac x \theta \right),</math>
then
<math>P(X > x) = P(Y < k).</math>
<math>X^2 \sim \Gamma\left(\frac{3}{2}, 2a^2\right).</math>

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 <math> f(x;k) \, (k > 1) </math> can be expressed as the product distribution of a Weibull distribution and a variant form of the stable count distribution. Its shape parameter <math> k </math> can be regarded as the inverse of Lévy's stability parameter in the stable count distribution: <math display="block">

   f(x;k) =
       \displaystyle\int_0^\infty \frac{1}{u} \, W_k\left(\frac{x}{u}\right)
       \left[ k u^{k-1} \, \mathfrak{N}_{\frac{1}{k}}\left(u^k\right) \right] \, du ,

</math> where <math>\mathfrak{N}_{\alpha}(\nu)</math> is a standard stable count distribution of shape <math> \alpha = 1/k</math>, and <math>W_k(x)</math> is a standard Weibull distribution of shape <math> k </math>.

Statistical inference

Parameter estimation

Maximum likelihood estimation

The likelihood function for Шаблон:Mvar iid observations Шаблон:Math is

<math>L(k, \theta) = \prod_{i=1}^N f(x_i;k,\theta)</math>

from which we calculate the log-likelihood function

<math>\ell(k, \theta) = (k - 1) \sum_{i=1}^N \ln x_i - \sum_{i=1}^N \frac{x_i} \theta - Nk\ln \theta - N\ln \Gamma(k)</math>

Finding the maximum with respect to Шаблон:Mvar by taking the derivative and setting it equal to zero yields the maximum likelihood estimator of the Шаблон:Mvar parameter, which equals the sample mean <math>\bar{x}</math> divided by the shape parameter Шаблон:Mvar:

<math>\hat{\theta} = \frac{1}{kN}\sum_{i=1}^N x_i = \frac{\bar{x}}{k}</math>

Substituting this into the log-likelihood function gives

<math>\ell(k) = (k-1)\sum_{i=1}^N \ln x_i -Nk - Nk\ln \left(\frac{\sum x_i}{kN} \right) - N\ln \Gamma(k)</math>

We need at least two samples: <math>N\ge2</math>, because for <math>N=1</math>, the function <math>\ell(k)</math> increases without bounds as <math>k\to\infty</math>. For <math>k>0</math>, it can be verified that <math>\ell(k)</math> is strictly concave, by using inequality properties of the polygamma function. Finding the maximum with respect to Шаблон:Mvar by taking the derivative and setting it equal to zero yields

<math>\ln k - \psi(k) = \ln\left(\frac{1}{N}\sum_{i=1}^N x_i\right) - \frac 1 N \sum_{i=1}^N \ln x_i = \ln \bar{x} - \overline{\ln x}</math>

where Шаблон:Mvar is the digamma function and <math>\overline{\ln x}</math> is the sample mean of Шаблон:Math. There is no closed-form solution for Шаблон:Mvar. 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 Шаблон:Mvar can be found either using the method of moments, or using the approximation

<math>\ln k - \psi(k) \approx \frac{1}{2k}\left(1 + \frac{1}{6k + 1}\right)</math>

If we let

<math>s = \ln \left(\frac 1 N \sum_{i=1}^N x_i\right) - \frac 1 N \sum_{i=1}^N \ln x_i = \ln \bar{x} - \overline{\ln x}</math>

then Шаблон:Mvar is approximately

<math>k \approx \frac{3 - s + \sqrt{(s - 3)^2 + 24s}}{12s}</math>

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

<math>k \leftarrow k - \frac{ \ln k - \psi(k) - s }{ \frac 1 k - \psi^{\prime}(k) }.</math>

At the maximum-likelihood estimate <math>(\hat k,\hat\theta)</math>, the expected values for Шаблон:Mvar and <math>\ln x</math> agree with the empirical averages:

<math>

\begin{align} \hat k\hat\theta &= \bar x &&\text{and} & \psi(\hat k)+\ln \hat\theta &= \overline{\ln x}. \end{align} </math>

Caveat for small shape parameter

For data, <math>(x_1,\ldots,x_N)</math>, that is represented in a floating point format that underflows to 0 for values smaller than <math>\varepsilon</math>, 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 <math>F(x;k,\theta)</math>, then the probability that there is at least one underflow is:

<math>

P(\text{underflow}) = 1-(1-F(\varepsilon;k,\theta))^N </math> This probability will approach 1 for small Шаблон:Mvar and large Шаблон:Mvar. For example, at <math>k=10^{-2}</math>, <math>N=10^4</math> and <math>\varepsilon=2.25\times10^{-308}</math>, <math>P(\text{underflow})\approx 0.9998</math>. 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 <math>k<1</math>. Following the implementation in scipy.stats.loggamma, this can be done as follows:[21] sample <math>Y\sim\text{Gamma}(k+1,\theta)</math> and <math>U\sim\text{Uniform}</math> independently. Then the required logarithmic sample is <math>Z=\ln(Y)+\ln(U)/k</math>, so that <math>\exp(Z)\sim\text{Gamma}(k,\theta)</math>.

Closed-form estimators

There exist consistent closed-form estimators of Шаблон:Mvar and Шаблон:Mvar that are derived from the likelihood of the generalized gamma distribution.[22]

The estimate for the shape Шаблон:Mvar is

<math>\hat{k} = \frac{N \sum_{i=1}^N x_i}{N \sum_{i=1}^N x_i \ln x_i - \sum_{i=1}^N x_i \sum_{i=1}^N \ln x_i} </math>

and the estimate for the scale Шаблон:Mvar is

<math>\hat{\theta} = \frac{1}{N^2} \left(N \sum_{i=1}^N x_i \ln x_i - \sum_{i=1}^N x_i \sum_{i=1}^N \ln x_i\right) </math>

Using the sample mean of Шаблон:Mvar, the sample mean of Шаблон:Math, and the sample mean of the product Шаблон:Math simplifies the expressions to:

<math>\hat{k} = \bar{x} / \hat{\theta}</math>
<math>\hat{\theta} = \overline{x\ln{x}} - \bar{x} \overline{\ln{x}}.</math>

If the rate parameterization is used, the estimate of <math>\hat{\beta} = 1/\hat{\theta}</math>.

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 Шаблон:Mvar is

<math>\tilde{\theta} = \frac{N}{N - 1} \hat{\theta}</math>

A bias correction for the shape parameter Шаблон:Mvar is given as[23]

<math>\tilde{k} = \hat{k} - \frac{1}{N} \left(3 \hat{k} - \frac{2}{3} \left(\frac{\hat{k}}{1 + \hat{k}}\right) - \frac{4}{5} \frac{\hat{k}}{(1 + \hat{k})^2} \right) </math>

Bayesian minimum mean squared error

With known Шаблон:Mvar and unknown Шаблон:Mvar, the posterior density function for theta (using the standard scale-invariant prior for Шаблон:Mvar) is

<math>P(\theta \mid k, x_1, \dots, x_N) \propto \frac 1 \theta \prod_{i=1}^N f(x_i; k, \theta)</math>

Denoting

<math> y \equiv \sum_{i=1}^Nx_i , \qquad P(\theta \mid k, x_1, \dots, x_N) = C(x_i) \theta^{-N k-1} e^{-y/\theta}</math>

Integration with respect to Шаблон:Mvar can be carried out using a change of variables, revealing that Шаблон:Math is gamma-distributed with parameters Шаблон:Math, Шаблон:Math.

<math>\int_0^\infty \theta^{-Nk - 1 + m} e^{-y/\theta}\, d\theta = \int_0^\infty x^{Nk - 1 - m} e^{-xy} \, dx = y^{-(Nk - m)} \Gamma(Nk - m) \!</math>

The moments can be computed by taking the ratio (Шаблон:Mvar by Шаблон:Math)

<math>\operatorname{E} [x^m] = \frac {\Gamma (Nk - m)} {\Gamma(Nk)} y^m</math>

which shows that the mean ± standard deviation estimate of the posterior distribution for Шаблон:Mvar is

<math> \frac y {Nk - 1} \pm \sqrt{\frac {y^2} {(Nk - 1)^2 (Nk - 2)}}. </math>

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 Шаблон:Mvar, inverse gamma with known shape parameter, and Gompertz with known scale parameter.

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

<math>p(k,\theta \mid p, q, r, s) = \frac{1}{Z} \frac{p^{k-1} e^{-\theta^{-1} q}}{\Gamma(k)^r \theta^{k s}},</math>

where Шаблон:Mvar is the normalizing constant with no closed-form solution. The posterior distribution can be found by updating the parameters as follows:

<math>\begin{align}
 p' &= p\prod\nolimits_i x_i,\\
 q' &= q + \sum\nolimits_i x_i,\\
 r' &= r + n,\\
 s' &= s + n,

\end{align}</math>

where Шаблон:Mvar is the number of observations, and Шаблон:Math is the Шаблон:Mvar-th observation.

Occurrence and applications

Consider a sequence of events, with the waiting time for each event being an exponential distribution with rate Шаблон:Mvar. Then the waiting time for the Шаблон:Mvar-th event to occur is the gamma distribution with integer shape <math>\alpha = n</math>. 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.[25] Examples include the waiting time of cell-division events,[26] number of compensatory mutations for a given mutation,[27] waiting time until a repair is necessary for a hydraulic system,[28] 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.[29]

The gamma distribution has been used to model the size of insurance claims[30] and rainfalls.[31] 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;Шаблон:Citation needed 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.[32][33]

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

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.[36]

In genomics, the gamma distribution was applied in peak calling step (i.e., in recognition of signal) in ChIP-chip[37] and ChIP-seq[38] 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[39] 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 Шаблон:Math. This parameterization means that the mean of this distribution is 1 and the variance is Шаблон:Math. Maximum likelihood and Bayesian methods typically use a discrete approximation to the continuous gamma distribution.[40][41]

Random variate generation

Given the scaling property above, it is enough to generate gamma variables with Шаблон:Math, as we can later convert to any value of Шаблон:Mvar with a simple division.

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

<math>-\sum_{k=1}^n \ln U_k \sim \Gamma(n, 1)</math>

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

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

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

  1. Generate Шаблон:Mvar, Шаблон:Mvar and Шаблон:Mvar as iid uniform (0, 1] variates.
  2. If <math>U\le\frac e {e+\delta}</math> then <math>\xi=V^{1/\delta}</math> and <math>\eta=W\xi^{\delta-1}</math>. Otherwise, <math>\xi=1-\ln V</math> and <math>\eta=We^{-\xi}</math>.
  3. If <math>\eta>\xi^{\delta-1}e^{-\xi}</math> then go to step 1.
  4. Шаблон:Mvar is distributed as Шаблон:Math.

A summary of this is

<math> \theta \left( \xi - \sum_{i=1}^{\lfloor k \rfloor} \ln U_i \right) \sim \Gamma (k, \theta)</math>

where <math>\scriptstyle \lfloor k \rfloor</math> is the integer part of Шаблон:Mvar, Шаблон:Mvar is generated via the algorithm above with Шаблон:Math (the fractional part of Шаблон:Mvar) and the Шаблон:Math are all independent.

While the above approach is technically correct, Devroye notes that it is linear in the value of Шаблон:Mvar and generally is not a good choice. Instead, he recommends using either rejection-based or table-based methods, depending on context.[42]Шаблон:Rp

For example, Marsaglia's simple transformation-rejection method relying on one normal variate Шаблон:Mvar and one uniform variate Шаблон:Mvar:[21]

  1. Set <math>d = a - \frac13</math> and <math>c = \frac1{\sqrt{9d}}</math>.
  2. Set <math>v=(1+cX)^3</math>.
  3. If <math>v > 0</math> and <math>\ln U < \frac{X^2}2 + d - dv + d\ln v</math> return <math>dv</math>, else go back to step 2.

With <math> 1 \le a = \alpha = k </math> generates a gamma distributed random number in time that is approximately constant with Шаблон:Mvar. The acceptance rate does depend on Шаблон:Mvar, with an acceptance rate of 0.95, 0.98, and 0.99 for k=1, 2, and 4. For Шаблон:Math, one can use <math> \gamma_\alpha = \gamma_{1+\alpha} U^{1/\alpha}</math> to boost Шаблон:Mvar to be usable with this method.

References

Шаблон:Reflist

External links

Шаблон:Wikibooks

Шаблон:ProbDistributions

  1. Шаблон:Cite journal
  2. Шаблон:Cite book
  3. Шаблон:Cite arXiv
  4. 4,0 4,1 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, Шаблон:Issn, [4].
  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. 7,0 7,1 Шаблон:Cite journal
  8. 8,0 8,1 Berg, Christian and Pedersen, Henrik L. "Convexity of the median in the gamma distribution".
  9. Шаблон:Cite journal
  10. 10,0 10,1 10,2 Шаблон:Cite journal
  11. 11,0 11,1 Шаблон:Cite journal
  12. Шаблон:Cite journal
  13. Шаблон:Cite journal
  14. W.D. Penny, [www.fil.ion.ucl.ac.uk/~wpenny/publications/densities.ps KL-Divergences of Normal, Gamma, Dirichlet, and Wishart densities]Шаблон:Full citation needed
  15. Шаблон:Cite web
  16. Шаблон:Cite web
  17. Шаблон:Cite journal
  18. Шаблон:Cite journal
  19. Шаблон:Cite journal
  20. Шаблон:Cite journal
  21. 21,0 21,1 Шаблон:Cite journal
  22. Шаблон:Cite journal
  23. Шаблон:Cite journal
  24. 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).
  25. Шаблон:Cite book
  26. Шаблон:Cite journal
  27. Шаблон:Cite journal
  28. Шаблон:Cite journal
  29. Шаблон:Cite journal
  30. p. 43, Philip J. Boland, Statistical and Probabilistic Methods in Actuarial Science, Chapman & Hall CRC 2007
  31. Шаблон:Cite journal
  32. Шаблон:Cite journal
  33. Шаблон:Cite journal
  34. 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)
  35. 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)
  36. 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.
  37. DJ Reiss, MT Facciotti and NS Baliga (2008) "Model-based deconvolution of genome-wide DNA binding", Bioinformatics, 24, 396–403
  38. 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
  39. Шаблон:Cite journal
  40. Шаблон:Cite journal
  41. Шаблон:Cite journal
  42. 42,0 42,1 42,2 Шаблон:Cite book See Chapter 9, Section 3.
  43. 43,0 43,1 Шаблон:Cite journal. See Algorithm GD, p. 53.
  44. Шаблон:Cite journal
  45. Шаблон:Cite journal
  46. Marsaglia, G. The squeeze method for generating gamma variates. Comput, Math. Appl. 3 (1977), 321–325.