In: Statistics and Probability
A coin is flipped repeatedly until either two heads appear in a row or two tails appear in a row(and then stop). Find the exact answer for P(two heads in a row appears before two tails in a row) for a coin with probability p of getting heads.
Probability of getting a head = p ; Probability of getting a tail = 1-p
Lets say we get two heads when we flip twice , probability of two heads in 2 flips ,P(2) = p * p = p2
Similarly, P(3) = (1-p) * p *p = p2 * (1-p) ( The first flip has to be tail)
Similarly, P(4) = p * (1-p) * p *p = p3 * (1-p). ( The first flip has to be head , 2nd has to be tail , 3rd & 4th has to be heads)
Similarly, P(5) = (1-p) * p * (1-p) * p *p = p3 * (1-p)2. (The first flip has to be tail , 2nd has to be head , 3rd has to be tail, 4th & 5th has to be heads).
Similarly, P(6) = p * (1-p) * p * (1-p) * p *p = p4 * (1-p)2. (The first flip has to be head , 2nd has to be tail , 3rd has to be head, 4th has to be tail ,5th & 6th has to be heads).
Similarly, P(7) = (1-p) * p * (1-p) * p * (1-p) * p *p = p4 * (1-p)3. (The first flip has to be tail , 2nd has to be head , 3rd has to be tail, 4th has to be head ,5th has to be tail, 6th & 7th has to be heads).
& so on.
Therefore the total probability , P = p2 + p2 * (1-p) + p3 * (1-p) + p3 * (1-p)2 + p4 * (1-p)2 + p4 * (1-p)3 + ....
P = ( p2 + p3 * (1-p)+ p4 * (1-p)2 + .... ) + (p2 * (1-p) + p3 * (1-p)2+ p4 * (1-p)3 + .... )
P = p2(1+ p(1-p) + p2(1-p)2 + ..) + p2(1-p) (1+ p(1-p) + p2(1-p)2 + ..)
P = + = =
Therefore, total probability =