← SciSim / Statistics

Gamma Distribution

Tier: Standard Undergraduate
§1 Interactive Simulation
Parameter 1
—
Parameter 2
—
Mean
—
Variance
—
Samples
0
Query prob
—
Parameter 1 —
Parameter 2 —
Query x —
Speed 20/s
§2 The Idea, Step by Step

Picture a bus stop where buses show up at random, one after another. The wait for a single bus is unpredictable, but suppose you actually need the third bus. How long until it finally arrives? That total waiting time — the sum of several random waits — is exactly what the Gamma distribution describes.

The wait for one event has its own simple law: the exponential distribution. The Gamma distribution stacks several of these waits together. It has two knobs. The shape $\alpha$ says roughly how many events you are waiting for, and the scale $\beta$ says how long each one takes on average. The expected total wait is just their product, the simplest equation here:

$$E[X]=\alpha\beta$$

So if buses average $\beta = 5$ minutes apart and you are waiting for $\alpha = 3$ of them, your expected total wait is $3 \times 5 = 15$ minutes. The spread around that grows too: the variance is $\text{Var}(X)=\alpha\beta^{2}$.

THE PRECISE FORM

The full density allows $\alpha$ to be any positive number, not just a whole count of events:

$$f(x;\alpha,\beta)=\frac{x^{\alpha-1}e^{-x/\beta}}{\beta^{\alpha}\,\Gamma(\alpha)},\quad x>0$$

The $\Gamma(\alpha)$ in the denominator is the gamma function — a smooth generalization of the factorial, with $\Gamma(n)=(n-1)!$ for whole numbers. It is what lets $\alpha$ slide continuously. The shape controls the look of the curve: $\alpha<1$ piles up near zero, $\alpha=1$ is the plain exponential, and large $\alpha$ pushes the bump rightward and makes it look nearly bell-shaped. On the panel above, Parameter 1 is $\alpha$, Parameter 2 is $\beta$, and the Query x slider reads off $P(X\le x)$ from the CDF.

TRY THIS IN THE SIM ABOVE

Set $\alpha=1$ and watch the curve collapse to the exponential — the law for waiting on a single event. Then crank $\alpha$ up toward 10 and see the hump drift right and turn bell-like (the central limit theorem at work as waits add up). Finally, hold $\alpha$ fixed and drag $\beta$ larger: the whole shape stretches to the right because the mean $\alpha\beta$ grows with it.

§3 Mathematical Derivation

Gamma Distribution — Sum of k exponentials; generalized waiting time

$$f(x;\alpha,\beta)=\frac{x^{\alpha-1}e^{-x/\beta}}{\beta^\alpha\Gamma(\alpha)},\quad x>0$$

$E[X]=\alpha\beta,\quad\text{Var}(X)=\alpha\beta^2$

KEY PROPERTIES

This distribution has important theoretical and applied properties. See the simulation tabs to explore how shape changes with parameters.

APPLICATIONS

Sum of k independent Exponential(λ) random variables. Time until k-th event in a Poisson process. Bayesian inference: conjugate prior for Poisson rate λ. Survival analysis baseline hazard. Insurance: total claim amount. Chi-squared is a special case: χ²(k) = Gamma(k/2, 2). Exponential is Gamma(1, 1/λ).

Key Results

Use the interactive simulation above to explore how the PDF shape responds to parameter changes. The Live Sampling tab demonstrates convergence of empirical frequencies to theoretical probabilities.

Ross — A First Course in Probability, 10th ed. 2019
Hogg, McKean & Craig — Introduction to Mathematical Statistics, 8th ed. 2018
DeGroot & Schervish — Probability and Statistics, 4th ed. 2012
§4 FAQ
StatQuest — youtube.com/@statquestSeeing Theory — seeing-theory.brown.edu
§5 Misconceptions & Common Errors
Key Error

Always verify parameter definitions before computing probabilities.
Different textbooks and software packages use different parameterizations. Always check which convention is being used (e.g., rate vs scale for exponential/gamma; shape vs rate for beta). Plug in extreme values and check that the PDF shape matches your expectation.
See the simulation to visualize how parameters affect the distribution shape.

Casella & Berger — Statistical Inference, 2nd ed. 2002
DeGroot & Schervish — Probability and Statistics, 4th ed. 2012
§6 Worked Example, Practice Problems and Uses
WORKED EXAMPLE: WAITING FOR THE THIRD CUSTOMER

Customers reach a stall at an average rate of 2 per hour, as a Poisson process. The time until the third customer is the sum of three exponential waiting times, so it follows a Gamma distribution with shape $\alpha=3$ and scale $\beta=0.5$ hours (this page uses the shape-scale form). Then $E[X]=\alpha\beta=1.5$ hours, $\text{Var}(X)=\alpha\beta^2=0.75$, so the standard deviation is about 0.87 hours. The mode is $(\alpha-1)\beta=1.0$ hour, below the mean, which is the signature of a right-skewed shape.

The probability that the third customer arrives within 2 hours is $P(X\le2)\approx0.762$, and within 1.5 hours (the mean) it is only $P(X\le1.5)\approx0.577$. The mean sits above the median because the long right tail pulls it up.

TRY THIS IN THE SIMULATION

Set Parameter 1 (shape $\alpha$) to 1 and watch the curve become the exponential distribution. Raise $\alpha$ step by step to 3, 6 and 10: the curve moves right and becomes more symmetric, as the central limit theorem predicts for a sum of many exponentials. Then keep $\alpha=2$ and change Parameter 2 (scale $\beta$): the shape stays the same and only the horizontal scale changes. Use the query slider on the CDF tab to confirm $P(X\le2)\approx0.76$ for $\alpha=3,\beta=0.5$.

PRACTICE PROBLEMS (ANSWERS BELOW)

1. Find the mean and variance of Gamma($\alpha=2$, $\beta=3$). 2. For that distribution, is $P(X>9)$ closer to 0.02, 0.2 or 0.6? 3. Which Gamma distribution is the same as chi-squared with 4 degrees of freedom?

Answers. 1. Mean $2\cdot3=6$, variance $2\cdot3^2=18$. 2. About 0.199, so 0.2. 3. Gamma($\alpha=2$, $\beta=2$), because $\chi^2(k)=\text{Gamma}(k/2,\,2)$; its mean is 4.

WHERE THE GAMMA DISTRIBUTION IS USED

It models the time until the k-th event in a Poisson process, total insurance claim size, rainfall totals, and waiting times in queues. In Bayesian statistics it is the conjugate prior for a Poisson rate. The exponential, chi-squared and Erlang distributions are all special cases, which is why the Gamma appears so often in statistics.

Ross — A First Course in Probability, 10th ed. 2019
Hogg, McKean & Craig — Introduction to Mathematical Statistics, 8th ed. 2018
DeGroot & Schervish — Probability and Statistics, 4th ed. 2012