# Probability in flipping a coin

Independent flips of a coin that lands on heads with probability p are made.

What is the probability that the pattern T, H, H, H occurs before the pattern H, H, H, H?

Hint: How can the pattern H, H, H, H occur first?

my approach is $\sum_{n=0}^\infty (1-p^4)^n(1-p)^3$ then i get $$\frac {(1-p)p^3}{1-(1-p^4)}$$

Am I wrong? What is the rationale behind the suggested answers?

Another answer I found online is: Our first observation is that for any 0 < p < 1 we will eventually see the pattern (H, H, H, H). Suppose that the first such pattern starts at the nth flip. If n > 1, then the n − 1th flip cannot be H since then the first (H, H, H, H) pattern would have started before the nth flip. Hence in this case the n − 1th flip is necessarily T, and starting with the n − 1th flip we see the pattern (T, H, H, H, H). In that sequence, (T, H, H, H) appears before (H, H, H, H). Summarizing, (H, H, H, H) can only appear before (T, H, H, H) if it starts immediately at the n = 1st flip, that is if all four first flips are heads. The probability of that is $p^4$.

-
I think you really ought to think about the hint!! A very substantial piece of information will emerge from that. If you use that, you get a very very quick answer. –  Michael Hardy Sep 21 '12 at 16:32
Actually, I agree with the hint but not with the suggested answer. What is your source? –  Did Sep 21 '12 at 16:48
one solution manual says $1-p$, the other one says it's $\frac {15}{16}$...x_x –  user133466 Sep 21 '12 at 16:57
What is(are) the source(s)? –  Did Sep 21 '12 at 18:03
Neither $1-p$ nor $\frac{15}{16}$ are correct for all values of $p$. The former is correct when $p=1$ and the latter when $p=\frac12$. –  Henry Sep 21 '12 at 18:25

In order to get $4$ consecutive Heads, you need to get $3$ consecutive Heads. However, getting $3$ consecutive heads ensure the first sequence if the last throw before the $3$ H was $T$, and the second one if it was $H$. So unless your $3$ H appears on start, you know you are done. Now the Only way for $HHHH$ to occur before THHH is to start with $4$ consecutive H. Can you see why that is?

We are going to prove that if you have a T in your first 4 throws, then THHH will appear first. Indeed, as mentionned above, getting four consecutive $H$ requires to get $3$ consecutive $H$ first. Suppose you have found your first $HHHH$ sequence somewhere in your string. Look at the throw before the first $H$. Either it is a $T$, in which case the sequence $THHH$ appeared first, or there is no throw because the first $H$ was your first throw. (It can't be a $H$ otherwise your $HHHH$ sequence would not be the first one to occur.) So the only way for $HHHH$ to come first is to start with it, which has probability $p^4$. So the answer you seek is $1-p^4$

-
errr, no not really... do you agree that the answer is 1-p? –  user133466 Sep 21 '12 at 20:08
Not really, the 1-p indicates that if you have a T on the first throw, then you will get the sequence THHH before HHHH, as I tried to explain. But you could get $HH$ on your first two throw and still get $THHH$ first. The only way for $HHHH$ to appear before $THHH$ is to get it from the start, which has a $1/p^4$. The answer you seek is then 1-1/p^4 –  Jean-Sébastien Sep 21 '12 at 20:18
First comment is what I'm saying, second doesn't really make sense to me... –  Jean-Sébastien Sep 21 '12 at 20:30
I found another answer and added to the body of my question. What do you think of that? –  user133466 Sep 21 '12 at 20:34
Jean gave the right answer and a sound explanation. If you have that why search the internet for some other anonymous student's answer? –  Michael Chernick Sep 21 '12 at 20:34

Here is a rigorous proof as to why the answer is $1-p^4$

Let E=event that pattern THHH occurs before HHHH and A=event that next 3 flips are heads

$P(E)=P(E|T)P(T)+P(E|H)P(H)$

$P(E|T)=P(E|T\cap A)P(A)+P(E|T\cap A^c)P(A^c)$

$P(E|T)=p^3+P(E|T)(1-p^3)$

$\Rightarrow P(E|T)=1$

Doing something similar for $P(E|H)$, we get $P(E|H)=P(E|T)(1-p^3)$

$\Rightarrow P(E)=1-p^4$

-