# The probability of having $k$ successes before $r$ failures in a sequence of independent Bernoulli trials

Problem

Find the probability of having $k$ successes before $r$ failures in a sequence of independent Bernoulli trials with $p$ being the probability of success.

I thought of using the Binomial distribution, the random variable $X$ is the number of successes, only this time I am interested not only in the number of successes but also in which order they are obtained. If the number of trials was $n$, then obviously I suppose $r+k \leq n$, I don't quite get the problem: the $k$ successes have to be one after the other, I mean, have to be $k$ successive successes?. I would like some explanation on the problem and suggestions of how could I calculate the probability I am being asked.

• My interpretation of the event the probability of which you are asked to find is: the $k$th success comes before the $r$th failure. They don't have to be consecutive: some failures may be mixed in. One approach (not necessarily best) is to introduce $t$, the number of trial that delivers the $k$th success, and observe that you are looking for probabilities of exactly $k$ successes in $t$ trials, summed over $t=k,\dots,k+r-1$.
– user147263
Aug 31, 2014 at 22:28
• This doesn't use measure theory, as required from probability-theory, thus removed. Same for probability-distributions; it is a question about the probability of a specific event. Aug 31, 2014 at 22:34
• Isn't this exactly the negative binomial distribution? Aug 31, 2014 at 22:35
• Imagine that you perform $k+r-1$ trials, even if the outcome ($k$ successes or $r$ failures) was already known earlier. Then the event "$k$ successes before $r$ failures" is the same (I mean exactly the same event, not just the same probability) as "at least $k$ successes in $k+r-1$ trials". Sep 2, 2014 at 13:53

Interpretation A

What is the probability of observing $k$ consecutive successes followed by $r$ consecutive failures?

It's a rather simple solution: The probability of succeeding is $p$, thus succeeding $k$ times independently has probability $p^k$. Same for failing $r$ times independently: $(1-p)^r$.
In total we have $$P = p^k (1-k)^r$$

Interpretation B

What is the probability that exactly $k$ successes occur before the $r$-th failure?

We need to put these $k$ successes in order with $r-1$ failures and obtain an additional failure (the $r$-th) giving $$P = \binom{k+r-1}k p^k (1-p)^{r-1} \cdot (1-p) = \binom{k+r-1}k p^k (1-p)^r$$

Interpretation C

What is the probability that (at least) $k$ successes are observed before the $r$-th failure occurs?

This is requesting at most $r-1$ failures before $k$ successes (see @Thursdays comment). In this case we have $$P = \sum_{j=0}^{r-1} \binom{k-1+j}{k-1} p^k (1-p)^j$$ as a solution

Thanks to @DilipSarvate for the interpretation titles
Thanks to @BrianMScott and @robjohn for spotting an error in the formula for interpretation C (after all this time)

• This is also the probability that $r$ failures occur followed by $k$ successes, isn't it? Aug 31, 2014 at 22:38
• @DilipSarwate It's also the probability of any specified order in wich $k$ successes and $r$ failures can occur. (for example alternating starting with a success if $k=r$) Aug 31, 2014 at 22:41
• @user100106: The answer for Interpretation C is wrong, I’m afraid; see this question and its accepted answer. Aug 27, 2015 at 19:56
• @robjohn Thanks... I now see where the double counting occurs. I think taking the binomial term to be $$\binom{k-1+j}{k-1}$$ should fix it. This makes the limit equal to $1$, as expected Jul 25, 2017 at 6:33
• @Did If you like, we can chat about that since it's not really on-topic for the particular question at hand. Jul 25, 2017 at 7:47

I take this to mean the probability of getting $k$ successes before the $r^\text{th}$ failure. To keep the cases separate, we case on the $k^\text{th}$ success.

The probability of $k-1$ successes and $j$ failures followed by a success is $\binom{k+j-1}{j}p^k(1-p)^j$. Thus, the probability of $k$ successes before $r$ failures is $$\sum_{j=0}^{r-1}\binom{k+j-1}{j}p^k(1-p)^j$$

As it should be, the limit as $r\to\infty$ is $1$ \begin{align} \sum_{j=0}^\infty\binom{k+j-1}{j}p^k(1-p)^j &=\sum_{j=0}^\infty(-1)^j\binom{-k}{j}p^k(1-p)^j\\ &=p^k(1-(1-p))^{-k}\\[12pt] &=1 \end{align}