What is the probability that a run of $n$ consecutive successes occurs before a run of $m$ consecutive failures? This example comes from the book "A First Course in Probability" by Sheldon Ross, Chapter 3, Section 3.5, Example 5C, Page 95. The example is given a solution but there is a part that I don't really understand. I hope someone can explain the logic to me.

The original question is as follow:

Independent trials, each resulting in a success with probability $p$ or a failure with probability $q = (1-p)$, are performed. We are interested in computing the probability that a run of $n$ consecutive successes occurs and before a run of $m$ consecutive failures. We are given the solution as follow:

Solution.: Let E be the event that a run of $n$ consecutive successes occurs before a run of $m$ consecutive failures. To obtain P(E), we start by conditioning on the outcomes of the first trial. That is letting H denote the event that the first trial results in a success, we obtain $$P(E) = pP(E|H)+qP(E|\bar H)$$ Now, given that the first trial was successful, one way we can get a run of $n$ successes before a run of $m$ failures would be to have the next $n-1$ trials all result in successes. So, let us condition on whether or not that occurs. That is, letting F be the event that trials 2 through n all are successes, we obtain $$P(E|H) = P(E|FH)P(F|H)+ P(E|\bar{F}H)P(\bar{F}|H)$$ On the one hand, clearly, P(E|FH) = 1; on the other hand, if the event $\bar{F}H$ occurs, then the first trial would result in a success, but there would be a failure some time during the next $n-1$ trials. However, when this failure occurs, it would wipe out all of the previous successes, and the situation would be exactly as if we started out with a failure. Hence, $$P(E|\bar{F}H) = P(E|\bar{H})$$
Pause !! This is the part where I don't really understand. I agree that when this failure occurs, it would wipe out all of the previous successes. But the situation for E to occur shouldn't be exactly the same as if we started out with a failure because if $F$ is the event that trials $2$ to $n$ are successes, then $\bar{F}$  is the event where not all $2$ to $n$ trials are successes. That being said, the last next $n-1$ trials could be successes. As an example, if the last two of $n-1$ trials is a failure then a success; then the situation for E to occur should be exactly the same as $P(E|H)$. So, can someone explain to me why $P(E|\bar{F}H) = P(E|\bar{H})$ ?
Since we are looking at an infinite number of trials, after removing a finite prefix of trials, we still have an infinite number of trials. Therefore, we can simply ignore this prefix for the probability of $E$ (even the conditions for $E$ would already be fulfilled by the prefix) and therefore $P(E) = P(E \mid B)$ for any event $B$ that restricts the outcomes of the trials only for a finite prefix.

This hopefully answers your question, but the partial solution you gave above seems rather complicated to me. Thankfully, I was able to find a pdf version of the book via Google. There, the author gives a rather complicated probability for $P(E)$ (not included in your question). That surprised me, because intuitively I thought, $P(E) = 1$.

Thinking about that in more detail, I am now convinced that, indeed, $P(E) = 1$: Let $A$ be the event, that we consecutively have $n$ successes and $m$ failures in $n + m$ trials. Clearly, $P(A) ≠ 0$, because $P(A) = p^n ⋅ q^m$ (assuming $0 &lt; p &lt; 1$).

Now let us iterate these $n + m$ trials and let $E'$ be the event that event $A$ occurs in the first block of $n + m$ trials, or in the second block of $n + m$ trials, or in the third block, etc. Since $P(A) ≠ 0$ and therefore $P(\overline{A}) ≠ 1$ it is easy to see that $P(\overline{E'}) = 0$, since we are looking at an infinite number of trials. Therefore we have $P(E') = 1$.

Since $E' ⊆ E$, it follows that also $P(E) = 1$.

For short: In an infinite sequence of trials you are able to find any finite pattern with probability $1$.

Therefore I suspect that there is a mistake in the solution in the book – unless I made a mistake myself or misunderstood the problem.
There are several errors which suggest a fundamental misunderstanding of probability on the behalf of the author of this textbook. For starters, this problem is not properly defined - how many trials are there in total? Are we talking about precisely $n+m$ trials, or perhaps some finite number $N&gt;n+m$, or an infinite sequence? The worked solution is inconsistent in which assumption it is using, and arrives at a conclusion which is incorrect regardless of which assumption we use. Let's go through it:


"One the one hand, clearly, $P(E|FH)=1$" - nope. $E$ is the event that we have $n$ successes followed by $m$ failures; $H$ is the event that the first trial is a success; $F$ is the event that the second through $n^\text{th}$ trials are successes. If we are assuming precisely $n+m$ trials, then given $F,H$, the event $E$ occurs if and only if trial $n+1$ through $m$ are failures. This clearly has probability less than $1$. Similarly, this will be less than $1$ (but larger than $P(E)$) if we have $N&gt;n+m$ trials. If we have an infinite number, then yes, this probability will be $1$; but this is no more "clear" than the original problem.
"Hence, $P(E|F^cH)=P(E|H^c)$" - what?! You gave a very simple counterexample which shows this is not the case. The instance of the first failure indeed "resets" the count in a sense, but we might have only a single failure on the second trial, in which case we still have $n-2$ successes in a row. If we are assuming $n+m$ trials, the probability is already zero; if we are assuming $N&gt;n+m+1$, this situation leaves us with a positive probability (whereas a later failure may make the probability zero) and if we are assuming infinitely many trials, then as before, each side is equal to $1$. (As Tony Dietze points out, since $E$ is an event only interested in the existence of a certain string, $P(E|C)=1$ for any event $C$ which depends only on finitely many trials.)
"Now, $GH^c$ is the event that the first $m$ trials all result in failures, so $P(E|GH^c) = 0$" - why? This is true if we have only $n+m$ trials, but then, $P(E|C)=0$ for any event $C$ which includes a failure in the first $n$ trials. In general, this statement is only true if we have $N&lt;n+2m$ total trials. The event $G$ is also an extremely strange event to condition on - why should we care if all the first $m$ trials are failures? Isn't one enough? Additionally, the author makes the same weird error as before, namely asserting that $G^cH^c$ involves a success wiping out all the previous failures and so claiming that $P(E|G^cH^c)=P(E|H)$. Absolute nonsense.
"Thus, $P(E)=\ldots=\frac{p^{n-1}(1-q^m)}{p^{n-1}+q^{m-1}-p^{n-1}q^{m-1}}$" - clearly not true. If there $n+m$ trials, then $E$ is precisely the event where the first $n$ are success, and the rest are failures, so $P(E)=p^nq^m$. If there are infinitely many trials, the reasoning Tony Dietze provided shows that $P(E)=1$ (intuitively speaking, if we run trials for long enough, eventually any finite string will appear). If there are $N&gt;n+m$ trials, $P(E)=P_N(E)$ must depend on $N$ with $P_N(E)\to1$ as $N\to\infty$.


It really blows my mind that such bad mathematics could appear in a textbook. I have not read any other part of this book, but if this example is anything to go by, you should get rid of it immediately and find a new textbook on probability.