Understanding the Negative Binomial Distribution

The negative binomial distribution models the number of trials needed to achieve a fixed number of successes. This post explains its formulation, real-world applications, and provides a visual example.
probability
discrete distributions
negative binomial
Author

Abdullah Al Mahmud

Published

June 3, 2026

Description

The negative binomial distribution is a discrete probability distribution that models the number of trials required to obtain a fixed number of successes (\(r\)) in a sequence of independent Bernoulli trials, each with success probability \(p\).

It generalizes the geometric distribution (which is the special case where \(r = 1\), i.e., waiting for the first success).


Probability Mass Function (PMF)

Two common formulations:

Type What it models PMF Support
Trials until \(r\)-th success Number of trials needed to get \(r\) successes \(P(X = k) = \binom{k-1}{r-1} p^r (1-p)^{k-r}\) \(k = r, r+1, r+2, \dots\)
Number of failures before \(r\)-th success Number of failures before the \(r\)-th success \(P(Y = y) = \binom{y+r-1}{r-1} p^r (1-p)^y\) \(y = 0, 1, 2, \dots\)

Here, the negative binomial can be seen as a sum of \(r\) independent geometric random variables.


Key Properties

  • Mean (trials formulation): \(E[X] = \frac{r}{p}\)
  • Variance (trials formulation): \(Var(X) = \frac{r(1-p)}{p^2}\)
  • Overdispersion: The variance is greater than the mean, making it suitable for count data with extra variability (unlike the Poisson distribution).

Categories of Use Cases

The negative binomial distribution is widely used in:

  1. Epidemiology – number of contacts until a certain number of disease transmissions occur
  2. Insurance / Actuarial Science – number of claims until a fixed number of payouts
  3. Sports Analytics – number of at‑bats until a player gets a certain number of hits
  4. Manufacturing – number of items produced until a fixed number of defects are found
  5. Machine Learning – modeling overdispersed count data (e.g., number of website visits per user)

Real-World Example

A basketball player has a free‑throw success probability of \(p = 0.70\). What is the probability that she makes her 3rd successful free throw on her 6th attempt?

Here: - \(r = 3\) successes - \(k = 6\) trials (includes the 3 successes) - \(p = 0.70\)

\(P(X = 6) = \binom{6-1}{3-1} (0.70)^3 (0.30)^{6-3}\)

\(= \binom{5}{2} (0.343) (0.027)\)

\(= 10 \times 0.343 \times 0.027 = 10 \times 0.009261 = 0.09261\)

So about 9.26%.


Density Curve (PMF) Visualization with R

library(ggplot2)

# Parameters
r <- 3      # number of successes
p <- 0.7    # success probability
k <- 3:15   # possible number of trials

# Probability mass function using dnbinom (failures formulation)
# Convert to trials: number of failures = k - r
prob <- dnbinom(k - r, size = r, prob = p)

# Create data frame
df <- data.frame(Trials = k, Probability = prob)

# Plot
ggplot(df, aes(x = Trials, y = Probability)) +
  geom_col(fill = "darkgreen", alpha = 0.7) +
  labs(title = paste("Negative Binomial Distribution (r =", r, ", p =", p, ")"),
       subtitle = "Number of trials to achieve 3 successes",
       x = "Number of trials", y = "Probability") +
  theme_minimal()


Comparison with Poisson Distribution

Feature Negative Binomial Poisson
Mean \(\frac{r(1-p)}{p}\) (failures form) \(\lambda\)
Variance \(\frac{r(1-p)}{p^2}\) \(\lambda\)
Variance / Mean \(\frac{1}{p} > 1\) \(1\)
Overdispersion ✅ Handles ❌ Assumes variance = mean

Thus, the negative binomial is often used as a robust alternative to the Poisson when count data exhibit overdispersion.


Key Takeaway

Use the negative binomial distribution when you want to model the number of trials needed to achieve a fixed number of successes, or when count data show more variability than a Poisson would allow. It is a flexible tool for overdispersed counts in real-world applications.


Further Reading