Data & Analysis Services for Industry & Education Brighton Webs Ltd.
Data & Analysis Services for Industry & Education

Home
Index
Feedback

Gamma Distribution

The gamma distribution represents the sum of n exponentially distributed random variables.  Both the shape and scale parameters can have non-integer values.

Typically, the gamma distribution is defined in terms of a scale factor and a shape factor.  When used to describe the sum of a series of exponentially distributed variables, the shape factor represents the number of variables and the scale factor is the mean of the exponential distribution.  This is apparent when the profile of an exponential distribution with mean set to one is compared to a gamma distribution with a shape factor of one and a mean of one.

Special cases of the gamma distribution include:

Exponential

When the shape parameter is set to one, and the scale parameter to the mean interval between events, the gamma distribution simplifies to the exponential.

Chi-Squared

A chi-squared distribution is a gamma distribution in which the shape parameter set to the degrees of freedom divided by two and the scale parameter set to two.

Erlang

The Erlang distribution is used to model the total interval associated with multiple Poisson events,  The shape parameters represents the number of events and the scale parameter the average interval between events.

Applications

Applications of the gamma distribution can be broadly put under two headings:

Applications based on intervals between events which derive from it being the sum of one or more exponentially distributed variables.  In this form, examples of its use include queuing models, the flow of items through manufacturing and distribution processes and the load on web servers and the many and varied forms of telecom exchange.

Due to its moderately skewed profile, it can be used as a model in a  range of disciplines, including climatology where it is a workable model for rainfall and financial services where it has been used for modelling insurance claims and the size of loan defaults and as such has been used in probability of ruin and value at risk calculations.

As with any distribution, it is important to check its "fitness for purpose".

Profile

Gamma Distribution - Variation in Probability Density with changing values of Scale and Shape Factors

Parameters

Parameter Description Characteristics
scale Determines the practical range. A float > 0
shape Determines the profile of the distribution A float > 0

Range

The range is from zero to infinity.

Functions

Gamma Distribution - Formula for Probability Density and & Cumulative Probability

Where is the gamma function and is the incomplete gamma function.

Properties

Gamma Distribution - Formula for properties

Example

The example below shows a simple model of insurance claims.  The average claim from from a given type of policy is $1,000 with a standard deviation of $250.  Using the matching moments formulas to estimate the parameters yields:

Scale = 2502/1000 = 62.5
Shape = 10002/2502 = 16

The probability density of the distribution is shown below:

Gamma Distribution - Insurance Claims Example

Parameters of this model are:

Modal claim $937
5% of claims will be less than $627
5% of claims will be greater than $1444

For this type of application, the parameters of the distribution should be determined by some form of curve fitting exercise with an acceptable quality of fit.

The second example uses the gamma distribution as a model for the August rainfall at Kew.

Gamma Distribution - Rainfall Example

The fit is significant at the 10%, which would make it a reasonable model for many applications, however, it does underestimate the number of months with low rainfall.

Random Number Generation

For integer values of shape factor, the gamma distribution is the sum of "shape" exponential distributions with mean equal to the scale factor.  Because the sum of log values, is equivalent to the log of their product, the formula can be simplified as shown in the pseudo basic style code shown below.

r = 1

   for  n=1 to shape
     r = r * rnd
   next n

r = - scale * log(r)

As there is no inverse probability function for the gamma distribution, some form of numerical technique has to be used.  On possibility is the method described in the section on non-uniform random number generation.

Parameter Estimation

The matching moment equations are obtained by rearranging and substituting variables in the equations for mean and variance:

Gamma Distribution - Parameter Estimation

Page Updated: 17-Nov-2004

 

For more information: info@brighton-webs.co.uk