[Math] Find the probability that exactly n trials are required

probability

Independent trials that result in a success with probability p are successively performed until a total of r successes is obtained. Find the probability that exactly n trials are required

Here is my (probably incorrect) attempt:

p: probability of success
$P_n$ = probability of success on nth trial

So in the first part of the equation I want the probability of n trials to have r successes, so I multiply the probability of success * 1- probability of n-1 trials being successful r times

For the second part of the equation I want the probability of n-1 trials, so I multiply the compliment of the probability r successes (1-p) multiplied by probability of n-1 trials being successful ($P_{n-1}$)

Let $P_n$=the probability that n trials result in r successes
$P_n=(1-P_{n-1})p+(1-p)P_{n-1}$

Best Answer

Direct enumeration: Clearly, if $n$ trials are needed to obtain $r$ successes, then the final trial must be the observation of the $r^{\rm th}$ success. For if not, then either the $r^{\rm th}$ success occurs before or after the $n^{\rm th}$ trial; in the former case, then there was no need to continue the trials because the $r^{\rm th}$ success was already observed, and in the latter, we cannot stop because the $r^{\rm th}$ success is yet to be observed.

Of the previous $n-1$ trials, there are $\binom{n-1}{r-1}$ ways that we could have observed the other $r-1$ successes in some order. Since the outcomes of all trials are independent, and $r-1$ of these trials are successes (and $n-r$ of these trials are failures), the resulting probability is $$\binom{n-1}{r-1} p^{r-1} (1-p)^{n-r}, \quad n = r, r+1, r+2, \ldots.$$ But this considers only the probability of all but the last trial. So for the last trial, which was a success with probability $p$, we get the desired probability $$\binom{n-1}{r-1} p^r (1-p)^{n-r}, \quad n = r, r+1, r+2, \ldots.$$

This probability distribution is known as the negative binomial distribution, and the above probability mass function gives the probability that $N = n$ trials are needed to observe the $r^{\rm th}$ success in a series of independent Bernoulli trials with success probability $p$.