# Probability of an event occuring n times before its complement occurs m times

Let the probability of event $E$ be $p$, and let $F$ be the complement of event $E$, so probability of event $F$ occurring is $1-p$. What is the probability of event $E$ occurring $n$ times before event $F$ occurs $m$ times?

• Welcome to MSE! Do you have any thoughts on the problem or have tried anything. It helps to share that. Regards Apr 23, 2013 at 3:48

We make the assumption that the outcomes of the trials are independent.

Imagine repeating the experiment $n+m-1$ times. Then exactly one of the following happens: (i) $E$ occurs at least $n$ times or (ii) $F$ occurs at least $m$ times.

So we want the probability that in $n+m-1$ trials, $E$ happens $n$ or more times. The probability of exactly $k$ occurrences of $E$ is $$\binom{n+m-1}{k}p^k(1-p)^{n+m-1-k}.$$

For the required probability, add up from $k=n$ to $k=n+m-1$.

Another way: We used the standard "trick" of imagining that the game continues for the full $n+m-1$ times even if a player has already "won." But we can make an alternate more complicated analysis. We find the probability that $E$ "wins" by finding the probability that $E$ gets her final win in the $n+k$-th game, where $k$ ranges from $0$ to $m-1$.

The probability that $E$ "wins the series" in round $n+k$ is calculated as follows. She needs exactly $n-1$ wins in the first $n+k-1$ trials, and then a win on the $n +k$-th. The probability of this is $\binom{n+k-1}{n-1}p^{n-1}(1-p)^k p$. Add up from $k=0$ to $k=m-1$. We get $$\sum_{k=0}^{m-1}\binom{n+k-1}{n-1}p^n(1-p)^k.$$ For estimates, particularly because estimation for the binomial is well-develped, the formula of the first answer is more useful.

• Can you please explain why the term n+m-1 choose k occurs? Apr 23, 2013 at 3:37
• actually, @AndreNicolas, shouldn't the binomial term be $\binom{m+n-2}{k-1}$ since we have to have a success on the last trial, we can only permute the trials before that? Apr 23, 2013 at 3:42
• It is the usual "binomial distribution" formula. Suppose we repeat an experiment independently $N$ times, where the probability of success each time is $p$. Then the probability of exactly $k$ successes is $\binom{N}{k}p^k(1-p)^{N-k}$. Consider any "word" of length $N$ that has $k$ $1$'s (for yes, success) and $N-k$ $0$'s (for no, failure). Each such string has probability $p^k(1-p)^{N-k}$. And there are $\binom{N}{k}$ such strings. Apr 23, 2013 at 3:44
• @ChristopherErnst: We do not have to have a success on the last trial. Apr 23, 2013 at 3:47
• We can't have $n$ successes and $0$ failures, because we are having a full $n+m-1$ trials, we don't stop if $E$ has won. But there is an alternate way of doing it, which will incorporate your idea. Recall the two ways of finding the probability that Team A wins the World Series. Apr 23, 2013 at 3:53

So E happens n times and F happens m-1 times. THus the maximum number of trials that can occur are n+m-1 and the minimum number of trials is of course n since we can have all successes. Thus, P(E occuring n times before M occurs m times is) $$\sum_{k=n}^{m+k-1}{\binom{m+n-1}{k}p^k(1-p)^{m+n-1-k}}$$