Gamma Distribution

The gamma distribution, also known as the Erlang distribution when the shape parameter is an integer, is a two-parameter family of continuous probability distributions. It is used to model the time until an event occurs a specified number of times.

Definition

The gamma distribution is characterized by two parameters: a scale parameter θ and a shape parameter α. Its probability density function (PDF) is:

f(x)=xα1ex/θΓ(α)θα

The cumulative distribution function (CDF) is expressed in terms of the incomplete gamma function:

F(x)=γ(α,x/θ)Γ(α)

The gamma distribution is defined for non-negative real values (x ≥ 0), with the shape parameter α and scale parameter θ being strictly positive real numbers.

An alternative parameterization uses the rate parameter λ=1/θ instead of the scale parameter θ. In this form, the PDF becomes:

f(x)=λαxα1eλxΓ(α)

This parameterization is sometimes preferred in statistical applications and Bayesian analysis because λ has a more direct interpretation as the rate of events.

Applications

The gamma distribution models many natural and engineering phenomena, particularly those involving waiting times and accumulated quantities.

  • Reliability engineering uses the gamma distribution to model the time until k failures occur in a system.

  • Meteorology applies the distribution to model rainfall amounts and other precipitation patterns.

  • Financial mathematics employs the gamma distribution in risk analysis and insurance claim modeling.

  • Queue theory uses the distribution to model service times in complex systems.

  • Statistical process control utilizes the gamma distribution for modeling skewed quality characteristics.

Properties

Statistical Properties
PropertyValue
Meanαθ
Varianceαθ2
Skewness2α
Excess Kurtosis6α
Medianθ(α13)
Mode(α1)θ for α1
Entropyα+ln(θΓ(α))+(1α)ψ(α)

The gamma distribution has these key mathematical properties:

  • The distribution is infinitely divisible.

  • The skewness is always positive, indicating a right-tailed distribution.

  • Both skewness and kurtosis decrease as α increases.

Relationships to Other Distributions

The gamma distribution connects to other probability distributions in several ways:

The GammaDistribution Class

The gamma distribution is implemented by the GammaDistribution class. It has five constructors with one to three arguments. The first argument is always the shape parameter. The second argument, if present, is the scale parameter. The default value is 1. The third argument specifies the location, with a default of zero.

The following constructs the same gamma distribution of order 4.2, scale parameter 1 and location parameter 0 using each of the three constructors:

C#
var gamma1 = new GammaDistribution(4.2, 1.0, 0.0);
var gamma2 = new GammaDistribution(4.2, 1.0);
var gamma3 = new GammaDistribution(4.2);

The GammaDistribution class has three specific properties, ShapeParameter, ScaleParameter, and LocationParameter, which return the shape, scale and location parameters of the distribution.

If a variable is assumed to have a gamma distribution, then the parameter of the distribution can be estimated using the method of maximum likelihood or the method of matching moments. The fourth and fifth constructors perform this calculation. The first argument is a Vector<T> whose distribution is to be estimated. The optional second parameter is a EstimationMethod value that specifies the method to be used. The default is the method of matching moments.

Note that parameter estimation says nothing about how well the estimated distribution fits the variable's distribution. Use one of the testing goodness-of-fit methods to verify the appropriateness of the choice of distribution.

GammaDistribution has one static (Shared in Visual Basic) method, Sample, which generates a random sample using a user-supplied uniform random number generator. It has three overloads, that take from 2 to 4 parameters. The first argument is the random number generator. The second to fourth parameters, if present, have the same meaning as the parameters of the constructor above.

C#
var random = new Pcg32();
double sample1 = GammaDistribution.Sample(random, 4.2, 1.0, 0.0);
double sample2 = GammaDistribution.Sample(random, 4.2, 1.0);
double sample3 = GammaDistribution.Sample(random, 4.2);

The above example uses the Pcg32 to generate uniform random numbers.

For details of the properties and methods common to all continuous distribution classes, see the topic on continuous distributions.

References

For more information on the gamma distribution, refer to the following sources:

  • Johnson, N. L., Kotz, S., & Balakrishnan, N. (1994). "Continuous Univariate Distributions, Volume 1", Chapter 17. Wiley Series in Probability and Statistics.

  • Forbes, C., Evans, M., Hastings, N., & Peacock, B. (2011). "Statistical Distributions", Chapter 22. Wiley Series in Probability and Statistics.

  • Casella, G., & Berger, R.L. (2002). Statistical Inference. Duxbury.

See Also