Explanation
The negative binomial distribution models the number of failures that accumulate before reaching a fixed number of successes \( r \) in a sequence of independent trials, each with the same success probability \( p \). It is a discrete distribution that generalizes the geometric distribution: when \( r = 1 \), it models the number of failures before the first success, equivalent to the failures-based geometric (support on \(\{0,1,2,\ldots\}\)), which differs by 1 from the variant that counts total trials (support on \(\{1,2,3,\ldots\}\)). Its mean is \( r(1-p)/p \) and its variance \( r(1-p)/p^2 \), always greater than the mean, which also makes it useful for modeling overdispersed counts where the variance exceeds the mean.
Use it when you want to answer questions like "how many failed attempts will there be before achieving \( r \) successes?" or, in its alternative parameterization, "how many trials in total are needed?". It is common in project management (attempts until closing contracts), clinical trials (recruiting \( r \) patients who respond), data science (modeling overdispersed counts) and reliability analysis. If count data show variance greater than the mean (overdispersion relative to Poisson), the negative binomial usually fits better.
Formula
$$ P(X=k)=\binom{k+r-1}{k}(1-p)^k p^r $$
Parameters
- r: desired number of successes.
- p: probability of success on each trial.
- k: number of failures observed before reaching the r successes.
Worked example
Situation: A researcher runs independent clinical trials, each with a success probability of \(p = 0.4\). They want to know how many failures accumulate before achieving exactly \(r = 3\) successes. Let \(X\) be the number of failures before the third success.
Question 1: What is the probability of getting exactly 5 failures before the third success, \(P(X = 5)\)?
Solution: We use the negative binomial PMF. The third success occurs on trial \(r + k = 3 + 5 = 8\), with the remaining 2 successes distributed among the first 7 trials: \[ P(X = 5) = \binom{r + k - 1}{k}\,p^r\,(1-p)^k = \binom{7}{5}(0.4)^3(0.6)^5 \] \[ = 21 \times 0.064 \times 0.07776 \approx 0.1045 \] There is approximately a 10.45% probability of accumulating exactly 5 failures before the third success.
Question 2: What is the expected number of failures before the third success, \(E[X]\)?
Solution: The mean of the negative binomial is: \[ E[X] = \frac{r(1-p)}{p} = \frac{3 \times 0.6}{0.4} = \frac{1.8}{0.4} = 4.5 \] On average, 4.5 failures are expected before completing 3 successes, implying an expected total of \(3 + 4.5 = 7.5\) trials.
Interpretation: With a 40% success rate, achieving 3 successes requires 7.5 attempts on average. Knowing this distribution allows planning resources and establishing confidence intervals for the total number of trials needed.