Gamma Distribution

Modeling waiting times and the sum of exponential variables.

The "Waiting Time" Distribution

The Gamma distribution is a versatile, two-parameter continuous probability distribution that is strictly positive. It's often used to model the waiting time until a specified number of events occur.

Think of it this way: if the time until the *next* bus arrives is modeled by an Exponential distribution, then the time until the *third* bus arrives is modeled by a Gamma distribution. In finance, it can be used to model the size of insurance claims, loan defaults, or operational losses, where the values are always positive and often skewed.

Interactive Gamma Distribution
Adjust the shape (α) and rate (β) parameters to see how the form of the distribution changes. Notice how for large α, it starts to resemble a normal distribution.
Mean (μ\mu): 2.00
Variance (σ2\sigma^2): 2.00

Core Concepts

Probability Density Function (PDF)
The PDF of the Gamma distribution is defined by a shape parameter α and a rate parameter β.
f(x;α,β)=βαΓ(α)xα1eβxf(x; \alpha, \beta) = \frac{\beta^\alpha}{\Gamma(\alpha)} x^{\alpha-1} e^{-\beta x}
  • x>0x > 0.
  • α>0\alpha > 0 (alpha) is the shape parameter. If `α` is an integer, it represents the number of events to wait for.
  • β>0\beta > 0 (beta) is the rate parameter (the inverse of the scale).
  • Γ(α)\Gamma(\alpha) is the Gamma function, a generalization of the factorial function.
Cumulative Distribution Function (CDF)
The CDF gives the probability that the event occurs on or before time xx.
F(x;α,β)=γ(α,βx)Γ(α)F(x; \alpha, \beta) = \frac{\gamma(\alpha, \beta x)}{\Gamma(\alpha)}

The CDF is expressed using the lower incomplete gamma function, γ(s,x)\gamma(s, x), and is usually computed numerically.

Key Derivations

Deriving the Moments (Mean and Variance)
We can derive the mean and variance using the definition of expected value and properties of the Gamma function.

Deriving the Expected Value (Mean)

Step 1: Set up the Integral for E[X]

The expected value is the integral of xx times the PDF over its entire range.

E[X]=0xβαΓ(α)xα1eβxdxE[X] = \int_{0}^{\infty} x \cdot \frac{\beta^\alpha}{\Gamma(\alpha)} x^{\alpha-1} e^{-\beta x} dx

Step 2: Simplify and Rearrange

Combine terms and move constants outside the integral.

E[X]=βαΓ(α)0xαeβxdxE[X] = \frac{\beta^\alpha}{\Gamma(\alpha)} \int_{0}^{\infty} x^{\alpha} e^{-\beta x} dx

Step 3: Use u-Substitution

Let u=βxu = \beta x, which implies x=u/βx = u/\beta and dx=du/βdx = du/\beta.

E[X]=βαΓ(α)0(uβ)αeuduβE[X] = \frac{\beta^\alpha}{\Gamma(\alpha)} \int_{0}^{\infty} (\frac{u}{\beta})^{\alpha} e^{-u} \frac{du}{\beta}
E[X]=βαΓ(α)1βα+10uαeuduE[X] = \frac{\beta^\alpha}{\Gamma(\alpha)} \cdot \frac{1}{\beta^{\alpha+1}} \int_{0}^{\infty} u^{\alpha} e^{-u} du

Step 4: Apply the Gamma Function Definition

The integral 0uαeudu\int_{0}^{\infty} u^{\alpha} e^{-u} du is the definition of Γ(α+1)\Gamma(\alpha+1).

E[X]=1βΓ(α)Γ(α+1)E[X] = \frac{1}{\beta \cdot \Gamma(\alpha)} \cdot \Gamma(\alpha+1)

Using the property Γ(z+1)=zΓ(z)\Gamma(z+1) = z\Gamma(z), we get Γ(α+1)=αΓ(α)\Gamma(\alpha+1) = \alpha\Gamma(\alpha).

E[X]=1βΓ(α)αΓ(α)=αβE[X] = \frac{1}{\beta \cdot \Gamma(\alpha)} \cdot \alpha\Gamma(\alpha) = \frac{\alpha}{\beta}
Final Mean Formula
E[X]=αβE[X] = \frac{\alpha}{\beta}

Deriving the Variance

We use Var(X)=E[X2](E[X])2Var(X) = E[X^2] - (E[X])^2. We first need to find E[X2]E[X^2].

Step 1: Set up the Integral for E[X²]

E[X2]=0x2βαΓ(α)xα1eβxdxE[X^2] = \int_{0}^{\infty} x^2 \cdot \frac{\beta^\alpha}{\Gamma(\alpha)} x^{\alpha-1} e^{-\beta x} dx
E[X2]=βαΓ(α)0xα+1eβxdxE[X^2] = \frac{\beta^\alpha}{\Gamma(\alpha)} \int_{0}^{\infty} x^{\alpha+1} e^{-\beta x} dx

Step 2: Apply u-Substitution Again

Using the same substitution u=βxu = \beta x.

E[X2]=βαΓ(α)1βα+20uα+1euduE[X^2] = \frac{\beta^\alpha}{\Gamma(\alpha)} \cdot \frac{1}{\beta^{\alpha+2}} \int_{0}^{\infty} u^{\alpha+1} e^{-u} du

Step 3: Apply Gamma Function Properties

The integral is Γ(α+2)\Gamma(\alpha+2), which equals (α+1)αΓ(α)(\alpha+1)\alpha\Gamma(\alpha).

E[X2]=1β2Γ(α)Γ(α+2)=(α+1)αΓ(α)β2Γ(α)=α(α+1)β2E[X^2] = \frac{1}{\beta^2 \Gamma(\alpha)} \cdot \Gamma(\alpha+2) = \frac{(\alpha+1)\alpha\Gamma(\alpha)}{\beta^2 \Gamma(\alpha)} = \frac{\alpha(\alpha+1)}{\beta^2}

Step 4: Calculate the Variance

Var(X)=E[X2](E[X])2=α(α+1)β2(αβ)2Var(X) = E[X^2] - (E[X])^2 = \frac{\alpha(\alpha+1)}{\beta^2} - \left(\frac{\alpha}{\beta}\right)^2
=α2+αβ2α2β2= \frac{\alpha^2 + \alpha}{\beta^2} - \frac{\alpha^2}{\beta^2}
Final Variance Formula
Var(X)=αβ2Var(X) = \frac{\alpha}{\beta^2}