Gamma Distribution
The gamma distribution with shape α and rate λ models waiting times, such as the time until the αth event in a Poisson process. Its density is f(x) = λ^α x^(α−1) e^(−λx)/Γ(α) for positive x, where Γ is the gamma function. Its mean is α/λ and its variance is α/λ².
Before this lesson: Exponential Distribution, Poisson Process and Improper Integrals
Waiting for more than one event
In a Poisson process, the wait for the first event is exponential. The wait for the third event is the sum of three exponential gaps. That sum is no longer exponential: it is very unlikely to be tiny, because three gaps all have to be short.
The gamma distribution describes waits like this. Its shape α counts how many exponential gaps are added, and its rate λ is the event rate. More gaps push the peak to the right and spread the curve out. The shape doesn’t have to be a whole number, which makes the gamma family a flexible model for any positive, right-skewed quantity.
The gamma function
The density needs a constant that makes its total area 1. That constant comes from the gamma function, defined for \alpha \gt 0 by
\Gamma(\alpha) = \int_0^\infty x^{\alpha - 1} e^{-x}\,dxIntegration by parts gives the rule Γ(α + 1) = αΓ(α). Since Γ(1) = 1, the gamma function extends factorials: Γ(n) = (n − 1)! for every whole number n. Another useful value is Γ(1/2) = √π.
\Gamma(\alpha + 1) = \alpha\,\Gamma(\alpha), \qquad \Gamma(n) = (n-1)!, \qquad \Gamma\left(\tfrac{1}{2}\right) = \sqrt{\pi}Gamma distribution formulas
X has a gamma distribution with shape \alpha \gt 0 and rate \lambda \gt 0, written X ~ Gamma(α, λ), when
f(x) = \dfrac{\lambda^\alpha x^{\alpha - 1} e^{-\lambda x}}{\Gamma(\alpha)} \text{ for } x \gt 0, \qquad E(X) = \dfrac{\alpha}{\lambda}, \qquad \operatorname{Var}(X) = \dfrac{\alpha}{\lambda^2}Two facts connect it to earlier lessons. Gamma(1, λ) is the exponential distribution Exp(λ). When α = n is a whole number, Gamma(n, λ) is the wait T_n until the nth event of a Poisson process with rate λ, and
P(T_n \gt t) = P(N(t) \le n - 1) = \sum_{k=0}^{n-1} \dfrac{e^{-\lambda t}(\lambda t)^k}{k!}Steps
- Identify the shape α and the rate λ. If you are given a scale β, use λ = 1/β.
- For the mean and variance, use α/λ and α/λ².
- For a probability with whole-number α, count Poisson events: the nth event comes after t exactly when at most n − 1 events happen by time t.
- For other α, use technology for the area under the density.
Gamma distribution examples
Example 1: Values of the gamma function
Find Γ(5) and Γ(3.5).
\Gamma(5) = 4! = 24
Use Γ(n) = (n − 1)!.
\Gamma(3.5) = 2.5\,\Gamma(2.5)
Use Γ(α + 1) = αΓ(α) with α = 2.5.
\Gamma(3.5) = 2.5 \cdot 1.5\,\Gamma(1.5)
Use the rule again with α = 1.5.
\Gamma(3.5) = 2.5 \cdot 1.5 \cdot 0.5\,\Gamma(0.5)
Use the rule again with α = 0.5.
\Gamma(3.5) = 1.875\sqrt{\pi} \approx 3.3234Multiply, and use Γ(1/2) = √π.
Answer: Γ(5) = 24 and Γ(3.5) = 1.875√π ≈ 3.3234.
Example 2: Deriving the mean
Show that X ~ Gamma(α, λ) has mean α/λ.
\int_0^\infty x^{a-1} e^{-\lambda x}\,dx = \int_0^\infty \dfrac{u^{a-1}}{\lambda^{a-1}} e^{-u} \dfrac{du}{\lambda} = \dfrac{\Gamma(a)}{\lambda^a}First a tool for any a: substitute u = λx (see u-substitution).
E(X) = \int_0^\infty x \cdot \dfrac{\lambda^\alpha x^{\alpha - 1} e^{-\lambda x}}{\Gamma(\alpha)}\,dx = \dfrac{\lambda^\alpha}{\Gamma(\alpha)} \int_0^\infty x^{\alpha} e^{-\lambda x}\,dxMultiply x by the density and pull out the constants.
E(X) = \dfrac{\lambda^\alpha}{\Gamma(\alpha)} \cdot \dfrac{\Gamma(\alpha + 1)}{\lambda^{\alpha + 1}}Use the tool with a = α + 1.
E(X) = \dfrac{\alpha\,\Gamma(\alpha)}{\Gamma(\alpha)\,\lambda} = \dfrac{\alpha}{\lambda}Use Γ(α + 1) = αΓ(α) and cancel.
Answer: E(X) = α/λ. The same tool with a = α + 2 gives E(X²) = α(α + 1)/λ², so Var(X) = α(α + 1)/λ² − α²/λ² = α/λ².
Example 3: Waiting for the third customer (word problem)
Customers arrive at a food truck as a Poisson process with a rate of 4 per hour. Find the mean and standard deviation of the wait for the third customer, and the probability that the third customer arrives within 30 minutes.
T_3 \sim \text{Gamma}(3, 4)The wait for the 3rd event has shape 3 and rate 4.
E(T_3) = \dfrac{3}{4} \text{ hour} = 45 \text{ minutes}Mean α/λ.
\sigma = \dfrac{\sqrt{3}}{4} \approx 0.433 \text{ hour} \approx 26 \text{ minutes}Square root of α/λ² = 3/16.
P(T_3 \le 0.5) = P(N(0.5) \ge 3)
The 3rd customer comes by time 0.5 exactly when at least 3 come by then.
\lambda t = 4(0.5) = 2
Mean count in half an hour.
P(N \ge 3) = 1 - e^{-2}\left(1 + 2 + \dfrac{2^2}{2}\right) = 1 - 5e^{-2}Use the complement rule with the Poisson terms for k = 0, 1, 2.
P(N \ge 3) \approx 1 - 0.6767 = 0.3233
Evaluate.
Answer: mean 45 minutes, standard deviation about 26 minutes, and probability about 0.3233.
Example 4: A probability by integration
X ~ Gamma(2, 1). Find P(X ≤ 1) by integrating the density.
f(x) = \dfrac{1^2 x^{1} e^{-x}}{\Gamma(2)} = x e^{-x}Substitute α = 2 and λ = 1; Γ(2) = 1! = 1.
P(X \le 1) = \int_0^1 x e^{-x}\,dxArea under the density from 0 to 1.
P(X \le 1) = \Big[-x e^{-x}\Big]_0^1 + \int_0^1 e^{-x}\,dxUse integration by parts with u = x and dv = e^(−x) dx.
P(X \le 1) = -e^{-1} + \Big[-e^{-x}\Big]_0^1 = -e^{-1} - e^{-1} + 1Evaluate both pieces.
P(X \le 1) = 1 - 2e^{-1} \approx 0.2642Combine like terms.
Answer: about 0.2642. Check: this is P(N(1) ≥ 2) = 1 − e^(−1) − e^(−1) for a Poisson process with rate 1.
Example 5: Fitting a gamma model (word problem)
Daily rainfall on rainy days at a weather station has mean 12 mm and variance 48 mm². Fit a gamma model, then find the probability that a rainy day gets more than 20 mm.
\dfrac{\alpha/\lambda}{\alpha/\lambda^2} = \lambda = \dfrac{12}{48} = 0.25Divide the mean by the variance.
\alpha = 12\lambda = 12(0.25) = 3
Solve mean = α/λ for α.
P(X \gt 20) = P(N(20) \le 2)
Whole-number shape: count events with rate 0.25 per mm.
\lambda t = 0.25(20) = 5
Mean count up to 20.
P(N \le 2) = e^{-5}\left(1 + 5 + \dfrac{5^2}{2}\right) = 18.5e^{-5}Add the Poisson terms for k = 0, 1, 2.
P(N \le 2) \approx 18.5 \times 0.0067379 \approx 0.1247
Evaluate.
Answer: Gamma(3, 0.25), and about 12.5% of rainy days get more than 20 mm.
Common mistakes
| Mistake | Example of the error | Fix |
|---|---|---|
| Mixing up rate and scale | Mean of Gamma(3, 4) = 3 × 4 = 12 | With rate λ, the mean is α/λ = 0.75. Only a scale β gives αβ. |
| Using n! for Γ(n) | Γ(5) = 120 | Γ(n) = (n − 1)!, so Γ(5) = 24. |
| Using the exponential for a later event | P(T_3 more than 0.5) = e^(−2) in Example 3 | The 3rd wait is Gamma(3, 4); count Poisson events instead. |
| Counting the wrong events | P(T_3 ≤ 0.5) = P(N(0.5) ≤ 3) | The 3rd event comes by t when N(t) ≥ 3. |
| Dropping Γ(α) from the density | Using x²e^(−x) as the Gamma(3, 1) density | Divide by Γ(3) = 2 so the area is 1. |
Related ideas
Erlang and chi-square distributions
A gamma distribution with a whole-number shape is also called an Erlang distribution, a name used in queueing and telephone traffic. The chi-square distribution with k degrees of freedom is Gamma(k/2, 1/2); it is the distribution behind chi-square tests.
Adding gamma variables
If X ~ Gamma(α₁, λ) and Y ~ Gamma(α₂, λ) are independent with the same rate, then X + Y ~ Gamma(α₁ + α₂, λ). For whole numbers this just adds more exponential gaps. The Convolution of Random Variables lesson in Unit 4 proves it.
Rate or scale?
Many books and programs use a scale β = 1/λ instead of a rate. Then the density is x^(α−1)e^(−x/β)/(Γ(α)β^α), the mean is αβ and the variance is αβ². Check which one a formula or program uses, as with the exponential distribution.
Practice problems
- Find Γ(6).
- Find Γ(4.5) in terms of √π and as a decimal.
- X ~ Gamma(4, 2). Find the mean, variance and standard deviation.
- X ~ Gamma(5, 0.5). Find the mean and variance.
- Events occur as a Poisson process with rate 3 per minute. Find the expected wait for the 2nd event and the probability that it takes more than 1 minute.
- X ~ Gamma(2, 3). Find f(1).
- A gamma model has mean 6 and variance 12. Find α and λ.
- Show that Gamma(1, λ) is the exponential distribution.
- Use the gamma function to find the integral of x³e^(−2x) from 0 to ∞.
- X is the sum of 4 independent Exp(0.5) waits. Name its distribution and find its mean and variance.
Show answers
1.
\Gamma(6) = 5! = 120
Use Γ(n) = (n − 1)!.
Answer: 120
2.
\Gamma(4.5) = 3.5 \cdot 2.5 \cdot 1.5 \cdot 0.5\,\Gamma(0.5)
Use Γ(α + 1) = αΓ(α) four times.
\Gamma(4.5) = 6.5625\sqrt{\pi} \approx 11.6317Multiply, and use Γ(1/2) = √π.
Answer: 6.5625√π ≈ 11.6317
3.
E(X) = \dfrac{4}{2} = 2Mean α/λ.
\operatorname{Var}(X) = \dfrac{4}{2^2} = 1Variance α/λ².
\sigma = \sqrt{1} = 1Take the square root.
Answer: mean 2, variance 1, standard deviation 1
4.
E(X) = \dfrac{5}{0.5} = 10Mean α/λ.
\operatorname{Var}(X) = \dfrac{5}{0.5^2} = \dfrac{5}{0.25} = 20Variance α/λ².
Answer: mean 10, variance 20
5.
E(T_2) = \dfrac{2}{3} \text{ minute}T_2 ~ Gamma(2, 3); mean α/λ.
P(T_2 \gt 1) = P(N(1) \le 1) = e^{-3}(1 + 3)At most 1 event in the first minute, with mean 3.
P(T_2 \gt 1) = 4e^{-3} \approx 0.1991Evaluate.
Answer: 2/3 minute (40 seconds); about 0.1991
6.
f(1) = \dfrac{3^2 \cdot 1^{1} e^{-3}}{\Gamma(2)} = \dfrac{9e^{-3}}{1}Substitute α = 2, λ = 3 and x = 1.
f(1) = 9e^{-3} \approx 0.4481Evaluate.
Answer: about 0.4481
7.
\lambda = \dfrac{6}{12} = 0.5Divide the mean by the variance.
\alpha = 6(0.5) = 3
Solve mean = α/λ for α.
Answer: α = 3, λ = 0.5
8.
f(x) = \dfrac{\lambda^1 x^{0} e^{-\lambda x}}{\Gamma(1)}Substitute α = 1.
f(x) = \lambda e^{-\lambda x}x⁰ = 1 and Γ(1) = 0! = 1.
Answer: the density is λe^(−λx) for positive x, the Exp(λ) density.
9.
\int_0^\infty x^3 e^{-2x}\,dx = \dfrac{\Gamma(4)}{2^4}Use the tool from Example 2 with a = 4 and λ = 2.
\int_0^\infty x^3 e^{-2x}\,dx = \dfrac{6}{16} = 0.375Γ(4) = 3! = 6.
Answer: 3/8 = 0.375
10.
X \sim \text{Gamma}(4, 0.5)A sum of 4 independent Exp(0.5) waits has shape 4.
E(X) = \dfrac{4}{0.5} = 8, \quad \operatorname{Var}(X) = \dfrac{4}{0.25} = 16Mean α/λ and variance α/λ².
Answer: Gamma(4, 0.5), mean 8, variance 16
Gamma distribution FAQ
What is the gamma distribution used for?
It models positive, right-skewed quantities, especially waiting times. Examples are the time until the nth customer arrives, the total of several service times, insurance claim sizes and rainfall amounts.
What is the gamma function?
It is Γ(α), the integral of x^(α−1)e^(−x) from 0 to ∞. It extends the factorial to non-whole numbers, with Γ(n) = (n − 1)! for whole numbers n.
How is the gamma distribution related to the exponential distribution?
The exponential distribution is the gamma distribution with shape 1. A gamma variable with whole-number shape n is the sum of n independent exponential variables with the same rate.
What do the shape and rate parameters do?
The shape α controls the form of the curve: shape 1 decays from the start, and larger shapes rise to a peak and look more symmetric. The rate λ stretches or squeezes the curve along the x-axis without changing its form.
Summary
- Gamma(α, λ) has density λ^α x^(α−1)e^(−λx)/Γ(α) for positive x.
- The mean is α/λ and the variance is α/λ².
- Γ(α + 1) = αΓ(α), Γ(n) = (n − 1)! and Γ(1/2) = √π.
- Gamma(1, λ) is Exp(λ), and Gamma(n, λ) is the wait for the nth event of a Poisson process.
- For whole-number shapes, find probabilities by counting Poisson events.
Previous lesson: Poisson Process
Next lesson: Functions of a Random Variable
Back to the Probability Theory Index