Understanding the Negative Binomial Distribution
Negative Binomial PMF (failures before the r-th success):
P(X = k) = C(k + r - 1, k) × pr × (1 - p)k
r = number of successes to reach; k = number of failures before the r-th success (k = 0, 1, 2, …); p = probability of success on each trial. C(k+r-1, k) is the binomial coefficient "k+r-1 choose k".
The negative binomial distribution answers a question the ordinary binomial cannot: instead of fixing the number of trials and counting successes, it fixes the number of successes r and asks how many failures k pile up before you get there. Each trial is an independent Bernoulli experiment with the same success probability p. The last trial in the sequence is always a success (the r-th one), which is why the coefficient is C(k+r-1, k) rather than C(k+r, k) — you are only free to arrange the first k failures and r−1 successes among the first k+r−1 trials.
Why the formula has each piece
- pr: every valid sequence contains exactly r successes, each contributing a factor of p.
- (1 - p)k: it also contains exactly k failures, each contributing a factor of (1 - p).
- C(k + r - 1, k): the number of distinct orderings of those k failures among the k+r−1 trials that precede the final, guaranteed r-th success.
Mean, variance, and over-dispersion
For this "number of failures" parameterization the expected number of failures is μ = r(1 - p)/p and the variance is σ² = r(1 - p)/p². Notice that the variance is always the mean divided by p, so it is strictly larger than the mean whenever p < 1. This "variance > mean" property, called over-dispersion, is exactly why statisticians reach for the negative binomial to model count data (insurance claims, disease cases, website purchases) that is too spread out for a Poisson model, where variance and mean are forced to be equal.
A worked example
Suppose you flip a fair coin (p = 0.5) and want the 3rd head (r = 3). What is the probability of exactly 2 tails before that 3rd head (k = 2)? Then C(2+3−1, 2) = C(4, 2) = 6, so P(X = 2) = 6 × 0.5³ × 0.5² = 6 × 0.03125 = 0.1875. On average you would expect r(1−p)/p = 3(0.5)/0.5 = 3 tails before the 3rd head.