Continuous distribution
Gamma distribution
The waiting time until the -th event of a Poisson process with rate , or the sum of independent exponential waits. With non-integer it is a general-purpose model for positive, right-skewed quantities such as rainfall or insurance claims, and it is the conjugate prior for a Poisson rate.
Gamma probability calculator
P(X ≤ 1.7) = 0.506754
At the parameters set by the sliders. The shaded region on the plot is the probability; the dots on the CDF mark F at its ends.
CDF
mean 2 · variance 2 · sd 1.414 · mode 1 · entropy 1.577 nats
Formulas
| Parameters |
|
|---|---|
| Support | |
| CDF | |
| Mean | |
| Variance | |
| Mode | |
| MGF | |
| Entropy |
is the regularized lower incomplete gamma function and the digamma function.
Worked example
Customers arrive at 2 per minute. What is the probability the third customer has arrived within 1 minute?
The wait is Gamma. It is at most 1 minute exactly when at least 3 arrive in the first minute, a Poisson(2) count: answer checked by code
How it relates to others
- Mixture→ Negative binomial: A Poisson count whose rate is itself Gamma() is Negative binomial(): the reason the negative binomial models over-dispersed counts. checked by code
- Sum← Exponential: The sum of independent Exponential() variables is Gamma() (the Erlang distribution). checked by code
- Special case→ Exponential: Gamma() is Exponential(). checked by code
- Special case→ Chi-squared: Gamma() is Chi-squared(). checked by code
- Transformation→ Beta: If are independent Gamma() and Gamma() with the same rate, is Beta(). checked by code
- Transformation→ Inverse gamma: If is Gamma() (rate ), is Inverse gamma() (scale ). checked by code
- Conjugate prior→ Poisson: A Gamma() prior on a Poisson rate and counts give a Gamma() posterior. checked by code
- Conjugate prior→ Exponential: A Gamma() prior on an exponential rate and observed times give a Gamma() posterior.
- Special case→ Erlang: A Gamma() with a whole-number shape is Erlang(). checked by code
All the relationships, as a diagram →
In Python
from scipy import stats
import numpy as np
X = stats.gamma(a=2, scale=1/1)
X.pdf(1.5) # f(1.5) = 0.3347
X.cdf(1.5) # P(X ≤ 1.5) = 0.4422
X.mean(), X.var() # 2, 2
X.ppf(0.95) # 95th percentile
X.rvs(size=10, random_state=0)
rng = np.random.default_rng(0)
rng.gamma(shape=2, scale=1/1, size=10)Both libraries take the scale 1/β, not the rate.
Choosing between this and its neighbours? Which distribution for waiting times and lifetimes? · Which prior distribution should I use?