Negative Binomial Distribution

The negative binomial distribution gives the probability that the rth success in a series of independent trials happens on trial x, when each trial succeeds with probability p: P(X = x) = \binom{x-1}{r-1}p^r(1-p)^{x-r} for x = r, r + 1, and so on. Its mean is r/p.

Before this lesson: Geometric Distribution, Binomial Distribution and Hypergeometric Distribution

Waiting for the rth success

A basketball player makes each shot with probability 0.6, and her shots are independent. She keeps shooting until she makes 3. How many shots will that take? The answer is random: it could be 3, 4, 5 or more.

The geometric distribution answers this question for the first success. The negative binomial waits for the rth success instead. The binomial distribution fixes the number of trials and counts successes; the negative binomial fixes the number of successes and counts trials.

For the 3rd make to come on shot 5, two things must happen. Shot 5 must be a make, and the first 4 shots must contain exactly 2 makes. Those 2 makes can sit in any of C(4, 2) = 6 places among the first 4 shots.

Negative binomial distribution formula

Run independent trials, each a success with probability p, until the rth success. Let X be the number of trials needed. Then X has a negative binomial distribution with parameters r and p:

P(X = x) = \binom{x-1}{r-1}p^r(1-p)^{x-r}, \qquad x = r,\ r+1,\ r+2,\ \ldots

The mean and variance are

E(X) = \dfrac{r}{p}, \qquad \operatorname{Var}(X) = \dfrac{r(1-p)}{p^2}

When r = 1, the formula becomes p(1-p)^{x-1}, the geometric distribution. In fact, X is the sum of r independent geometric waiting times, one for each success. That is why the mean is r times the geometric mean 1/p.

Steps

  1. Check that the trials are independent, each with the same success probability p, and that you stop at the rth success.
  2. Identify r and x, the trial on which the rth success happens.
  3. Count the ways to place r − 1 successes among the first x − 1 trials: C(x − 1, r − 1).
  4. Multiply by p^r for the r successes and (1-p)^{x-r} for the x − r failures.

Negative binomial distribution examples

Example 1: The third made shot

A player makes each shot with probability 0.6, independently. Find the probability that her 3rd made shot is her 5th shot.

r = 3,\quad p = 0.6,\quad x = 5

Identify the values.

\binom{4}{2} = \dfrac{4 \cdot 3}{2} = 6

Place 2 makes among the first 4 shots (see permutations and combinations).

(0.6)^3 = 0.216

Probability of the 3 makes.

(0.4)^2 = 0.16

Probability of the 2 misses.

P(X = 5) = 6(0.216)(0.16)

Multiply the three parts.

P(X = 5) = 0.20736

Multiply.

Answer: about 0.2074. The graph shows the whole distribution. The most likely count is 4 shots, and the mean is 3/0.6 = 5 shots.

Bar graph of P(X = x), the probability that the 3rd success happens on trial x when p = 0.6, for x = 3 to 12. The bars are 0.216, 0.259, 0.207, 0.138, 0.083, 0.046, 0.025, 0.013, 0.006 and 0.003. The bar at x = 5 is highlighted, and a dashed line marks the mean, 5 trials.
The orange bar is Example 1: the 3rd make comes on shot 5 with probability 0.207. The long right tail pulls the mean (5) above the most likely value (4).

Example 2: Sales calls (word problem)

A salesperson closes a sale on 20% of her calls, independently. She needs 2 sales today. Find the probability that her 2nd sale comes on her 5th call, and the expected number of calls she must make.

r = 2,\quad p = 0.2,\quad x = 5

Identify the values.

\binom{4}{1} = 4

Place the 1 earlier sale among the first 4 calls.

P(X = 5) = 4(0.2)^2(0.8)^3

Substitute into the formula.

P(X = 5) = 4(0.04)(0.512)

Evaluate the powers.

P(X = 5) = 0.08192

Multiply.

E(X) = \dfrac{2}{0.2} = 10

Mean formula.

Answer: about 0.0819, and she should expect to make 10 calls.

Example 3: Mean and standard deviation

An oil company drills wells until it finds 3 productive ones. Each well is productive with probability 0.25, independently. Find the mean and standard deviation of the number of wells drilled.

E(X) = \dfrac{3}{0.25} = 12

Mean formula with r = 3 and p = 0.25.

1 - p = 0.75

Probability of a dry well.

\operatorname{Var}(X) = \dfrac{3(0.75)}{(0.25)^2}

Variance formula.

\operatorname{Var}(X) = \dfrac{2.25}{0.0625} = 36

Evaluate, then divide.

\sigma = \sqrt{36} = 6

Take the square root.

Answer: mean 12 wells, standard deviation 6 wells.

Example 4: The rth success by a deadline

Each trial succeeds with probability 0.3, independently. Find the probability that the 2nd success happens on or before trial 4.

P(X = 2) = \binom{1}{1}(0.3)^2 = 0.09

The first two trials both succeed.

P(X = 3) = \binom{2}{1}(0.3)^2(0.7) = 2(0.09)(0.7) = 0.126

One success in the first 2 trials, then a success.

P(X = 4) = \binom{3}{1}(0.3)^2(0.7)^2 = 3(0.09)(0.49) = 0.1323

One success in the first 3 trials, then a success.

P(X \le 4) = 0.09 + 0.126 + 0.1323 = 0.3483

Add the cases.

Check with the binomial: the 2nd success comes by trial 4 exactly when 4 trials give at least 2 successes.

1 - (0.7)^4 - 4(0.3)(0.7)^3 = 1 - 0.2401 - 0.4116

Subtract the chances of 0 and 1 success from 1.

1 - 0.2401 - 0.4116 = 0.3483

Subtract.

Answer: 0.3483. Both methods agree.

Example 5: Winning a best-of-seven series

Team A wins each game against Team B with probability 0.6, independently. The first team to win 4 games wins the series. Find the probability that Team A wins in exactly 6 games, and the probability that Team A wins the series.

P(X = 6) = \binom{5}{3}(0.6)^4(0.4)^2

Team A’s 4th win comes in game 6.

P(X = 6) = 10(0.1296)(0.16) = 0.20736

Evaluate the powers and multiply.

P(\text{A wins}) = \sum_{x=4}^{7} \binom{x-1}{3}(0.6)^4(0.4)^{x-4}

Team A’s 4th win must come by game 7.

P(\text{A wins}) = 0.1296\left[1 + 4(0.4) + 10(0.16) + 20(0.064)\right]

Factor out (0.6)⁴ = 0.1296.

P(\text{A wins}) = 0.1296(1 + 1.6 + 1.6 + 1.28)

Multiply inside the brackets.

P(\text{A wins}) = 0.1296(5.48) = 0.710208

Add, then multiply.

Answer: about 0.2074 for exactly 6 games, and about 0.7102 for winning the series. A 60% edge in each game becomes a 71% edge over a series.

Common mistakes

MistakeExample of the errorFix
Using C(x, r) instead of C(x − 1, r − 1)C(5, 3)(0.6)³(0.4)² = 0.3456 in Example 1The last trial must be the rth success, so only the first x − 1 trials are arranged: C(4, 2).
Using the binomial formulaAnswering Example 1 with the chance of 3 makes in 5 shots, 0.3456The binomial allows the 3rd make before shot 5. The negative binomial requires shot 5 to be the 3rd make.
Mixing up trials and failuresUsing r(1 − p)/p = 2 as the mean number of shots in Example 1r(1 − p)/p is the mean number of failures. The mean number of trials is r/p = 5.
Allowing x below rFinding a nonzero P(X = 2) when r = 3At least r trials are needed, so P(X = x) = 0 when x is less than r.
Forgetting the square in the varianceVar(X) = 3(0.75)/0.25 = 9 in Example 3Divide by p² = 0.0625 to get 36.

Related forms

Counting failures instead of trials

Some books and software (R and SciPy, for example) define the negative binomial as Y, the number of failures before the rth success. Then Y = X − r, and

P(Y = k) = \binom{k+r-1}{k}p^r(1-p)^k, \qquad E(Y) = \dfrac{r(1-p)}{p}

Check which form a problem or calculator uses before you plug in. The variance is r(1 − p)/p² in both forms.

Why it is called negative binomial

The probabilities add to 1 because of the binomial series with a negative exponent. Summing \binom{k+r-1}{k}(1-p)^k over k = 0, 1, 2, … gives (1-(1-p))^{-r} = p^{-r}, and multiplying by p^r gives 1.

Mean and variance from geometric waiting times

Write X as the sum of r independent geometric variables, each with mean 1/p and variance (1 − p)/p². By the rules for combining random variables, the means add to r/p and the variances add to r(1 − p)/p².

Counts with extra spread

Count data whose variance is larger than its mean is called overdispersed. The Poisson distribution forces the variance to equal the mean, so statisticians often model counts such as insurance claims with the failures form of the negative binomial instead.

Practice problems

  1. A fair coin is tossed until the 2nd head. Find the probability that it takes exactly 4 tosses.
  2. A fair die is rolled until the 2nd six appears. Find the probability that this happens on the 6th roll.
  3. For r = 4 and p = 0.8, find the mean and variance of X, the number of trials.
  4. When r = 3, what are the possible values of X?
  5. Show that the negative binomial formula with r = 1 gives the geometric distribution.
  6. A fair coin is tossed until the 3rd head. Find the probability that this takes 5 or fewer tosses.
  7. Y is the number of failures before the 2nd success, with p = 0.4. Find P(Y = 3).
  8. Find the mean number of failures before the 5th success when p = 0.25.
  9. In a best-of-five series, a team wins each game with probability 0.55, independently. Find the probability that it wins the series in exactly 4 games.
  10. A recruiter needs 3 qualified applicants, and each applicant is qualified with probability 0.15, independently. Find the mean and standard deviation of the number of applicants she interviews.
Show answers

1.

r = 2,\quad p = 0.5,\quad x = 4

Identify the values.

P(X = 4) = \binom{3}{1}(0.5)^2(0.5)^2

Substitute into the formula.

P(X = 4) = 3 \cdot \dfrac{1}{16} = \dfrac{3}{16}

Multiply.

Answer: 3/16 = 0.1875

2.

P(X = 6) = \binom{5}{1}\left(\dfrac{1}{6}\right)^2\left(\dfrac{5}{6}\right)^4

r = 2, p = 1/6 and x = 6.

P(X = 6) = 5 \cdot \dfrac{1}{36} \cdot \dfrac{625}{1296}

Evaluate the powers.

P(X = 6) = \dfrac{3125}{46{,}656} \approx 0.0670

Multiply the fractions.

Answer: about 0.0670

3.

E(X) = \dfrac{4}{0.8} = 5

Mean formula.

\operatorname{Var}(X) = \dfrac{4(0.2)}{(0.8)^2} = \dfrac{0.8}{0.64}

Variance formula.

\operatorname{Var}(X) = 1.25

Divide.

Answer: mean 5, variance 1.25

4.

x \ge r = 3

At least 3 trials are needed for 3 successes.

Answer: X = 3, 4, 5, and so on (every whole number from 3 up)

5.

P(X = x) = \binom{x-1}{0}p^1(1-p)^{x-1}

Substitute r = 1.

P(X = x) = p(1-p)^{x-1}

Use C(x − 1, 0) = 1.

Answer: this is the geometric distribution formula, so the trial of the first success is geometric.

6.

P(X = 3) = \binom{2}{2}(0.5)^3 = \dfrac{1}{8} = \dfrac{4}{32}

The 3rd head on toss 3.

P(X = 4) = \binom{3}{2}(0.5)^4 = \dfrac{3}{16} = \dfrac{6}{32}

The 3rd head on toss 4.

P(X = 5) = \binom{4}{2}(0.5)^5 = \dfrac{6}{32}

The 3rd head on toss 5.

P(X \le 5) = \dfrac{4 + 6 + 6}{32} = \dfrac{16}{32} = \dfrac{1}{2}

Add, then simplify.

Answer: 1/2, the same as the chance of at least 3 heads in 5 tosses

7.

P(Y = 3) = \binom{4}{3}(0.4)^2(0.6)^3

Failures form with k = 3 and r = 2, so C(k + r − 1, k) = C(4, 3).

P(Y = 3) = 4(0.16)(0.216) = 0.13824

Evaluate the powers and multiply.

Answer: about 0.1382

8.

E(Y) = \dfrac{5(0.75)}{0.25} = \dfrac{3.75}{0.25} = 15

Mean number of failures, r(1 − p)/p.

Answer: 15 failures (20 trials in all)

9.

P(X = 4) = \binom{3}{2}(0.55)^3(0.45)

The team’s 3rd win comes in game 4.

P(X = 4) = 3(0.166375)(0.45) \approx 0.2246

Evaluate the power and multiply.

Answer: about 0.2246

10.

E(X) = \dfrac{3}{0.15} = 20

Mean formula.

\operatorname{Var}(X) = \dfrac{3(0.85)}{(0.15)^2} = \dfrac{2.55}{0.0225} \approx 113.33

Variance formula.

\sigma = \sqrt{113.33} \approx 10.65

Take the square root.

Answer: mean 20 applicants, standard deviation about 10.65

Negative binomial distribution FAQ

What is the negative binomial distribution used for?

It models how many independent trials it takes to reach a fixed number of successes, such as calls until 2 sales or games until a team’s 4th win. In statistics it is also used for count data whose variance is larger than its mean.

What is the difference between the binomial and negative binomial distributions?

The binomial fixes the number of trials and counts the successes. The negative binomial fixes the number of successes and counts the trials needed to reach them.

What is the mean of the negative binomial distribution?

The mean number of trials is r/p, and the variance is r(1 − p)/p². If you count failures instead of trials, the mean is r(1 − p)/p.

How is the negative binomial related to the geometric distribution?

The geometric distribution is the case r = 1. A negative binomial variable is the sum of r independent geometric waiting times.

Summary

  • The negative binomial distribution gives the probability that the rth success happens on trial x.
  • P(X = x) = \binom{x-1}{r-1}p^r(1-p)^{x-r} for x = r, r + 1, and so on.
  • E(X) = r/p and Var(X) = r(1 − p)/p².
  • With r = 1 it is the geometric distribution; in general it is a sum of r geometric waiting times.
  • Some books count failures, Y = X − r, so check which form a problem uses.

Previous lesson: Hypergeometric Distribution

Next lesson: Probability Density Functions

Back to the Probability Theory Index