Difference between revisions of "Gamma distribution"

(All four functions on same page)
Line 7: Line 7:
  
 
<center>[[image:Gamma(7,10).png]]</center>
 
<center>[[image:Gamma(7,10).png]]</center>
 +
 +
Use the [[Gamma]] distribution with «alpha» > 1 if you have a sharp lower bound of zero but no sharp upper bound, a single mode, and a
 +
positive skew. The [[LogNormal]] distribution is also an option in this case. [[Gamma]]() is especially appropriate when encoding arrival
 +
times for sets of events. A gamma distribution with a large value for «alpha» is also useful when you wish to use a bell-shaped curve for
 +
a positive-only quantity.
  
 
The gamma distribution is bounded below by zero (all sample points are positive) and is unbounded from above. It has a theoretical mean of <code>alpha*beta</code> and a theoretical variance of <code>alpha*beta^2</code>. When «alpha» > 1, the distribution is unimodal with the mode at <code>(alpha - 1)*beta</code>. An exponential distribution results when <code>alpha = 1</code>. As <math>\alpha \to \infty</math> , the gamma distribution approaches a normal distribution in shape.
 
The gamma distribution is bounded below by zero (all sample points are positive) and is unbounded from above. It has a theoretical mean of <code>alpha*beta</code> and a theoretical variance of <code>alpha*beta^2</code>. When «alpha» > 1, the distribution is unimodal with the mode at <code>(alpha - 1)*beta</code>. An exponential distribution results when <code>alpha = 1</code>. As <math>\alpha \to \infty</math> , the gamma distribution approaches a normal distribution in shape.
Line 28: Line 33:
 
{{Release||5.1|To use this, you need to add the [[Distribution Densities Library]] to your model, or use [[GammaI]] instead. }}
 
{{Release||5.1|To use this, you need to add the [[Distribution Densities Library]] to your model, or use [[GammaI]] instead. }}
  
The cumulative density up to «x».
+
The cumulative density up to «x», given for <math>x>0</math> by
 +
:<math>F(x) = {1\over {\Gamma(\alpha)}} \int_0^x \beta^{-\alpha} t^{\alpha-1} \exp(-t/\beta) dt</math>
 +
 
 +
This is also the same as the regularized incomplete gamma function, computed by the function [[GammaI]].
  
 
=== <div id="CumGammaInv">CumGammaInv(p, alpha'', beta'')</div> ===
 
=== <div id="CumGammaInv">CumGammaInv(p, alpha'', beta'')</div> ===
 
{{Release||5.1|To use this, you need to add the [[Distribution Densities Library]] to your model, or use [[GammaIInv]] instead. }}
 
{{Release||5.1|To use this, you need to add the [[Distribution Densities Library]] to your model, or use [[GammaIInv]] instead. }}
  
The inverse cumulative probability function (quantile function).
+
The analytic inverse cumulative probability function (quantile function). Returns the p<sup>th</th> fractile/quantile/percentile for the gamma distribution. Same as the inverse incomplete gamma function, [[GammaIInv]].
  
 
== When to use ==
 
== When to use ==
Line 42: Line 50:
  
 
== Statistics ==
 
== Statistics ==
 
+
The theoretical statistics (i.e., in the absence of sampling error) for the gamma distribution are as follows.
 +
* <math>0<x<\infty</math>
 +
* <math>\alpha, \beta>0</math>
 +
* [[Mean]] = <math>\alpha \beta</math>
 +
* [[Mode]] = <math>Max([0, \alpha-1) \beta])</math>
 +
* [[Variance]] = <math>\alpha \beta^2</math>
 +
* [[SDeviation]] = <math>\beta \sqrt{\alpha}</math>
 +
* [[Skewness]] = <math>2 / \sqrt{\alpha}</math>
 +
* [[Kurtosis]] = <math>6 / \alpha</math>
  
 
== Parameter Estimation ==
 
== Parameter Estimation ==
 
Suppose <code>X</code> contains sampled historical data indexed by <code>I</code>.  To estimate the parameters of the gamma distribution that best fits this sampled data, the following parameter estimation formulae can be used:
 
Suppose <code>X</code> contains sampled historical data indexed by <code>I</code>.  To estimate the parameters of the gamma distribution that best fits this sampled data, the following parameter estimation formulae can be used:
:<code>alpha := Mean(X, I)^2/Variance(X, I)</code>
+
:<code>alpha := [[Mean]](X, I)^2/[[Variance]](X, I)</code>
:<code>beta  := Variance(X, I)/Mean(X, I)</code>
+
:<code>beta  := [[Variance]](X, I)/[[Mean]](X, I)</code>
  
 
The above is not the maximum likelihood parameter estimation, which turns out to be rather complex (see [http://en.wikipedia.org/wiki/Gamma_Distribution#Maximum_likelihood_estimation Wikipedia]).  However, in practice the above estimation formula perform excellently and are so convenient that more complicated methods are hardly justified.
 
The above is not the maximum likelihood parameter estimation, which turns out to be rather complex (see [http://en.wikipedia.org/wiki/Gamma_Distribution#Maximum_likelihood_estimation Wikipedia]).  However, in practice the above estimation formula perform excellently and are so convenient that more complicated methods are hardly justified.
Line 55: Line 71:
  
 
To estimate all three parameters, the following heuristic estimation can be used:
 
To estimate all three parameters, the following heuristic estimation can be used:
:<code>alpha  := 4/Skewness(X, I)^2</code>
+
:<code>alpha  := 4/[[Skewness]](X, I)^2</code>
:<code>offset := Mean(X, I) - SDeviation(X, I)*Sqrt(alpha)</code>
+
:<code>offset := [[Mean]](X, I) - [[SDeviation]](X, I)*[[Sqrt]](alpha)</code>
:<code>beta  := Variance(X, I)/(Mean(X, I) - offset)</code>
+
:<code>beta  := [[Variance]](X, I)/([[Mean]](X, I) - offset)</code>
  
 
== See Also ==
 
== See Also ==

Revision as of 21:50, 10 October 2018


The Gamma distribution is a continuous, positive-only, unimodal distribution that encodes the time required for «alpha» events to occur in a Poisson process with mean arrival time of «beta»

Gamma(7,10).png

Use the Gamma distribution with «alpha» > 1 if you have a sharp lower bound of zero but no sharp upper bound, a single mode, and a positive skew. The LogNormal distribution is also an option in this case. Gamma() is especially appropriate when encoding arrival times for sets of events. A gamma distribution with a large value for «alpha» is also useful when you wish to use a bell-shaped curve for a positive-only quantity.

The gamma distribution is bounded below by zero (all sample points are positive) and is unbounded from above. It has a theoretical mean of alpha*beta and a theoretical variance of alpha*beta^2. When «alpha» > 1, the distribution is unimodal with the mode at (alpha - 1)*beta. An exponential distribution results when alpha = 1. As [math]\displaystyle{ \alpha \to \infty }[/math] , the gamma distribution approaches a normal distribution in shape.

Functions

Note

Some textbooks use Rate = 1/beta, instead of «beta», as the scale parameter.

Gamma(alpha, beta, over)

The distribution function. Use this to describe a quantity that is gamma-distributed with shape parameter «alpha» and scale parameter «beta». The scale parameter, «beta», is optional and defaults to beta = 1.

Dens_Gamma(x, alpha, beta)

To use this, you need to add the Distribution Densities Library to your model.

The analytic probability density of the Gamma distribution at «x». Returns

[math]\displaystyle{ p(x) = {{\beta^{-\alpha} x^{\alpha-1} \exp(-x/\beta)}\over{\Gamma(\alpha)}} }[/math]

CumGamma(x, alpha, beta)

To use this, you need to add the Distribution Densities Library to your model, or use GammaI instead.

The cumulative density up to «x», given for [math]\displaystyle{ x\gt 0 }[/math] by

[math]\displaystyle{ F(x) = {1\over {\Gamma(\alpha)}} \int_0^x \beta^{-\alpha} t^{\alpha-1} \exp(-t/\beta) dt }[/math]

This is also the same as the regularized incomplete gamma function, computed by the function GammaI.

CumGammaInv(p, alpha, beta)

To use this, you need to add the Distribution Densities Library to your model, or use GammaIInv instead.

The analytic inverse cumulative probability function (quantile function). Returns the p

th fractile/quantile/percentile for the gamma distribution. Same as the inverse incomplete gamma function, GammaIInv.

When to use

Use the Gamma distribution with «alpha» > 1 if you have a sharp lower bound of zero but no sharp upper bound, a single mode, and a positive skew. The LogNormal distribution is also an option in this case. Gamma() is especially appropriate when encoding arrival times for sets of events. A gamma distribution with a large value for «alpha» is also useful when you wish to use a bell-shaped curve for a positive-only quantity.

Statistics

The theoretical statistics (i.e., in the absence of sampling error) for the gamma distribution are as follows.

  • [math]\displaystyle{ 0\lt x\lt \infty }[/math]
  • [math]\displaystyle{ \alpha, \beta\gt 0 }[/math]
  • Mean = [math]\displaystyle{ \alpha \beta }[/math]
  • Mode = [math]\displaystyle{ Max([0, \alpha-1) \beta]) }[/math]
  • Variance = [math]\displaystyle{ \alpha \beta^2 }[/math]
  • SDeviation = [math]\displaystyle{ \beta \sqrt{\alpha} }[/math]
  • Skewness = [math]\displaystyle{ 2 / \sqrt{\alpha} }[/math]
  • Kurtosis = [math]\displaystyle{ 6 / \alpha }[/math]

Parameter Estimation

Suppose X contains sampled historical data indexed by I. To estimate the parameters of the gamma distribution that best fits this sampled data, the following parameter estimation formulae can be used:

alpha := Mean(X, I)^2/Variance(X, I)
beta := Variance(X, I)/Mean(X, I)

The above is not the maximum likelihood parameter estimation, which turns out to be rather complex (see Wikipedia). However, in practice the above estimation formula perform excellently and are so convenient that more complicated methods are hardly justified.

The Gamma distribution with an «offset» has the form:

Gamma(alpha, beta) - offset

To estimate all three parameters, the following heuristic estimation can be used:

alpha := 4/Skewness(X, I)^2
offset := Mean(X, I) - SDeviation(X, I)*Sqrt(alpha)
beta := Variance(X, I)/(Mean(X, I) - offset)

See Also

Comments


You are not allowed to post comments.