Gamma Distribution
Gamma Distribution
Definition
Core Statement
The Gamma Distribution models the time until
Purpose
- Waiting Times: How long until 5 customers arrive? How long until the 3rd component fails?
- Reliability Engineering: Modeling fatigue life where damage accumulates.
- Bayesian Statistics: Conjugate prior for the rate parameter of a Poisson or Exponential likelihood.
- Financial Modeling: Asset sizes or insurance claims (skewed, positive data).
Relations (The Family Tree)
- Exponential: Gamma with shape
. (Wait for 1st event). - Chi-Square: Gamma with specific parameters (
). - Erlang: Gamma where
is an integer.
Worked Example: Multiple Failures
Problem
A server crashes on average once every 2 days (
Question: What is the probability that the 3rd crash happens within 10 days?
Setup:
- Events to wait for (
or ): 3. - Rate (
or ): 0.5. - This is Gamma(3, 0.5).
Calculation:
Using Python or Tables (
Intuition: Since average time per crash is 2 days, 3 crashes take ~6 days. So 10 days is plenty of time. 87.5% chance.
Parameters
Warning: Different fields use different parametrizations!
- Shape-Scale (
): Mean = . (Engineering). - Shape-Rate (
): Mean = . (Bayesian/Math). .
Python Implementation
from scipy.stats import gamma
import matplotlib.pyplot as plt
# Parameters (using 'a' as shape alpha)
alpha = 3 # Wait for 3 events
loc = 0
scale = 2 # Mean time per event (theta = 1/beta) (If rate=0.5, scale=2)
rv = gamma(alpha, loc=loc, scale=scale)
# Probability wait < 10
prob = rv.cdf(10)
print(f"Prob < 10: {prob:.4f}")
# Plot
import numpy as np
x = np.linspace(0, 20, 100)
plt.plot(x, rv.pdf(x))
plt.title("Gamma Distribution (k=3, theta=2)")
plt.show()
Related Concepts
- Exponential Distribution - Special case (
). - Poisson Distribution - Counts events in fixed time (Dual concept).
- Chi-Square Distribution - Another special case.
- Beta Distribution - Associated conjugate prior.