Unit 6, lesson 41

The Negative Binomial Distribution

How the negative binomial distribution counts the trials needed for the rth success, why its stopping rule fixes the last trial, and how the failure-count form, geometric waiting times and binomial tails describe it.

  • Video 41
  • Counting and Waiting in Independent Trials

Suppose a task needs three successful attempts, each attempt succeeds with probability 0.40.4 independently of the others, and you stop as soon as the third success arrives. Now the number of successes is fixed and the number of attempts is random, the reverse of the binomial setup. How likely is it that exactly five attempts are needed, how many should you expect, and how likely is it that you finish within five? This lesson answers each question by fixing the final success, splitting the wait into geometric pieces and rewriting a deadline as a binomial count.

Key terms

Stopping rule

Definition In a sequence of trials, a stopping rule decides after each trial whether to stop, using only the outcomes observed so far. A binomial experiment stops after a fixed number nn of trials whatever the outcomes, so the number of trials is fixed and the number of successes is random. The negative binomial experiment stops as soon as the number of successes reaches a fixed positive integer rr, so the number of successes is fixed at rr and the number of trials is random.

In plain words A stopping rule is the instruction for when the experiment ends. The binomial fixes the trials and counts successes, and the negative binomial fixes the successes and counts trials. The rule also decides which sequences can appear as a complete record.

Example Take r=3r = 3 and write S for a success and F for a failure. The record S, F, S, S ends after trial 44, because the third success has just occurred, and the recorded count is 44. The sequence S, S, S, F, F is a possible outcome of five binomial trials, but it is not a complete record under this stopping rule, because the experiment ends after the third trial.

Negative binomial distribution

Definition Let rr be a positive integer and 0<p≤10 < p \le 1. Trials are independent, each a success with probability pp, and the waiting time for the rrth success, TT, is the number of trials up to and including the rrth success. The event {T=k}\{T = k\} happens exactly when trial kk is a success and the first k−1k - 1 trials contain exactly r−1r - 1 successes. Choosing the positions of those earlier successes gives

P(T=k)=(k−1r−1)pr(1−p)k−r\begin{aligned} &P(T = k) \\[0.4em] &\quad = \binom{k-1}{r-1} p^{r} (1 - p)^{k - r} \end{aligned}

for every integer k≥rk \ge r, and P(T=x)=0P(T = x) = 0 for every other real xx. This is the negative binomial distribution with parameters rr and pp in the trial-count convention, and its support is {r,r+1,r+2,… }\{r, r + 1, r + 2, \dots\} when p<1p < 1. For r=1r = 1 the coefficient is 11 and the formula is the geometric PMF. When p=1p = 1 the formula, with the usual convention (1−p)0=1(1 - p)^0 = 1, gives T=rT = r with certainty, so the support is {r}\{r\}. The value p=0p = 0 is excluded, because then the target is reached with probability 00.

In plain words The last trial is forced to be a success. All the freedom lies in where the other r−1r - 1 successes fall among the earlier trials, and every such arrangement has rr successes and k−rk - r failures, so every arrangement has the same probability.

Example With r=3r = 3 and p=0.4p = 0.4, the event T=5T = 5 needs a success on trial 55 and exactly two successes among trials 11 to 44. There are (42)=6\binom{4}{2} = 6 arrangements, each with probability (0.4)3(0.6)2(0.4)^3 (0.6)^2, so

P(T=5)=6 (0.4)3(0.6)2=4323125=0.13824.\begin{aligned} &P(T = 5) = 6\,(0.4)^3 (0.6)^2 \\[0.4em] &\quad = \tfrac{432}{3125} = 0.13824. \end{aligned}

Using (53)\binom{5}{3} in place of (42)\binom{4}{2} gives 0.23040.2304, the binomial probability of exactly three successes in five trials. That count also includes sequences such as S, S, S, F, F, in which the third success comes before trial 55.

Failure-count form

Definition With the same rr and pp, let FF be the number of failures before the rrth success. Then F=T−rF = T - r, its support is {0,1,2,… }\{0, 1, 2, \dots\} when p<1p < 1 and {0}\{0\} when p=1p = 1, and substituting k=f+rk = f + r in the trial-count formula gives

P(F=f)=(f+r−1r−1)×pr(1−p)f\begin{aligned} P(F = f) &= \binom{f + r - 1}{r - 1} \\[0.4em] &\quad \times p^{r} (1 - p)^{f} \end{aligned}

for every integer f≥0f \ge 0. Some references define the negative binomial distribution by this form. Shifting by the constant rr lowers the mean by rr and leaves the variance unchanged, so quote a probability or a mean together with its convention.

In plain words Both forms describe the same experiment. The trial count includes the rr successes and the failure count leaves them out, so the two records always differ by exactly rr.

Example With r=3r = 3 and p=0.4p = 0.4, five trials in total means two failures, so P(F=2)=(42)(0.4)3(0.6)2=4323125P(F = 2) = \binom{4}{2}(0.4)^3(0.6)^2 = \tfrac{432}{3125}, the same number as P(T=5)P(T = 5). The mean failure count is 7.5−3=4.57.5 - 3 = 4.5 while the mean trial count is 7.57.5, and both counts have variance 11.2511.25. A reported mean of 4.54.5 and a reported mean of 7.57.5 can describe the same model.

Sum of geometric waiting times

Definition Let G1G_1 be the number of trials up to and including the first success, and for i=2,…,ri = 2, \dots, r let GiG_i be the number of further trials after the (i−1)(i - 1)th success up to and including the iith. Then T=G1+⋯+GrT = G_1 + \dots + G_r. For positive integers g1,…,grg_1, \dots, g_r, the event that Gi=giG_i = g_i for every ii fixes the outcome of each of the first g1+⋯+grg_1 + \dots + g_r trials, so with q=1−pq = 1 - p its probability is

∏i=1rq gi−1 p.\prod_{i=1}^{r} q^{\,g_i - 1}\,p.

This product of geometric masses shows that G1,…,GrG_1, \dots, G_r are independent and each is geometric with parameter pp. Expectations add, and variances of independent variables add, so

E[T]=rp,Var⁡(T)=r(1−p)p2.\begin{gathered} E[T] = \frac{r}{p}, \\[0.4em] \operatorname{Var}(T) = \frac{r(1 - p)}{p^2}. \end{gathered}

The failure count F=T−rF = T - r has E[F]=r(1−p)/pE[F] = r(1 - p)/p and the same variance.

In plain words Waiting for the rrth success is rr waits for a first success, one after another. Each block starts fresh because the trials are independent with one constant pp. For r≥2r \ge 2 and p<1p < 1 the total wait does not forget its past the way a geometric wait does, since what remains depends on how many successes have already occurred. Once that number is known, the rest of the wait is a fresh negative binomial wait for the successes still needed.

Example With r=3r = 3 and p=0.4p = 0.4, each block has mean 1/0.4=2.51/0.4 = 2.5 and variance 0.6/0.16=3.750.6/0.16 = 3.75. So E[T]=7.5E[T] = 7.5 and Var⁡(T)=3⋅3.75=11.25\operatorname{Var}(T) = 3 \cdot 3.75 = 11.25, a standard deviation of about 3.353.35 trials. A mean that is not a whole number is still an average of whole-number waits. If the first two trials are both successes, one success is still needed and the expected remaining wait is 2.52.5 trials. If both are failures, three are still needed and the expected remaining wait is 7.57.5 trials.

Deadline probability as a binomial tail

Definition Let TT be the waiting time for the rrth success, and for a positive integer nn let XnX_n be the number of successes among the first nn trials of the same sequence, so Xn∼Bin⁡(n,p)X_n \sim \operatorname{Bin}(n, p). The rrth success has occurred by trial nn exactly when the first nn trials contain at least rr successes. Hence

P(T≤n)=P(Xn≥r)=∑j=rn(nj)pj(1−p)n−j.\begin{aligned} &P(T \le n) = P(X_n \ge r) \\[0.4em] &\quad = \sum_{j=r}^{n} \binom{n}{j} p^{j} (1 - p)^{n-j}. \end{aligned}

For n<rn < r the sum is empty and the probability is 00. The model is the whole sequence of independent trials, and stopping at the rrth success only means that later trials are not needed. Both events depend only on the first nn trials. The complement gives P(T>n)=P(Xn≤r−1)P(T > n) = P(X_n \le r - 1).

In plain words A deadline question about a waiting time is a counting question about a fixed number of trials. Finishing by trial nn and having at least rr successes in the first nn trials are one event described in two ways.

Example With r=3r = 3, p=0.4p = 0.4 and n=5n = 5, finishing by trial 55 means at least three successes in five trials. The binomial probabilities of three, four and five successes are 0.23040.2304, 0.07680.0768 and 0.010240.01024, so

P(T≤5)=P(X5≥3)=0.31744.\begin{aligned} P(T \le 5) &= P(X_5 \ge 3) \\[0.4em] &= 0.31744. \end{aligned}

Adding negative binomial masses gives the same value, since P(T=3)+P(T=4)+P(T=5)=0.064+0.1152+0.13824P(T = 3) + P(T = 4) + P(T = 5) = 0.064 + 0.1152 + 0.13824. The deadline probability is larger than P(T=5)=0.13824P(T = 5) = 0.13824 because it also includes finishing on trial 33 or trial 44.

Check yourself

  1. Independent trials each succeed with probability 12\tfrac12, and TT counts the trials up to and including the second success. Find P(T=4)P(T = 4).
Show the answer

Trial 44 must be a success, and exactly one of trials 11 to 33 must succeed. There are (31)=3\binom{3}{1} = 3 arrangements, S, F, F, S and F, S, F, S and F, F, S, S, each with probability (12)4=116(\tfrac12)^4 = \tfrac{1}{16}. So P(T=4)=316P(T = 4) = \tfrac{3}{16}.

  1. In the same model, find E[T]E[T], Var⁡(T)\operatorname{Var}(T) and the probability of finishing by trial 33.
Show the answer

With r=2r = 2 and p=12p = \tfrac12, the mean is E[T]=2/12=4E[T] = 2/\tfrac12 = 4 and the variance is

Var⁡(T)=2⋅1214=4.\operatorname{Var}(T) = \frac{2 \cdot \tfrac12}{\tfrac14} = 4.

Finishing by trial 33 means at least two successes in three trials. The binomial probabilities of two and three successes are 38\tfrac38 and 18\tfrac18, so P(T≤3)=12P(T \le 3) = \tfrac12. As a check, P(T=2)=14P(T = 2) = \tfrac14 and P(T=3)=(21)(12)3=14P(T = 3) = \binom{2}{1}(\tfrac12)^3 = \tfrac14 also add to 12\tfrac12.

  1. A student computes P(T=4)P(T = 4) in the same model as (42)(12)4=38\binom{4}{2}(\tfrac12)^4 = \tfrac38. What does this number count, and why is it too large?
Show the answer

The number 38\tfrac38 is the binomial probability of exactly two successes in four fixed trials. Of the six sequences with two successes, three end with a success and have T=4T = 4. The other three, S, S, F, F and S, F, S, F and F, S, S, F, end with a failure, so their second success came on trial 22 or 33 and the experiment would already have stopped. Removing them leaves 38−316=316\tfrac38 - \tfrac{3}{16} = \tfrac{3}{16}. The stopping rule requires the last trial to be a success, so only the earlier success positions are chosen, with (31)\binom{3}{1} rather than (42)\binom{4}{2}.

How this lesson connects