Friday, 29 November 2013

combinatorics - Flip a Fair Coin


I found this question and became curious, can anyone tell me the answer and prove it, i know it seems fairly simple but just thought an explanation of this would make an interesting case.


Flip a fair coin repeatedly until you get two heads in a row (HH assuming H indicates head and T indicates Tails). On average, how many flips should this take? What if we flip until we get heads followed by tails (HT)? Are the answers the same?



Answer



Case 1: Waiting for HH


$A$ = average nb. of flips to get HH after T or nothing.

$B$ = average nb. of flips to get HH after H.


A is 1 flip, plus B if you get H and continue, or plus A if you get T and restart:
$A = 1 + {1\over2}B + {1\over2}A$


B is 1 flip, and you are done if you get H, or plus A if you get T and restart:
$B = 1 + {1\over2}0 + {1\over2}A$


This resolves to


$B = 1 + {1\over 2}A$
$A = 1 + {1\over 2} (1 + {1\over 2} A) + {1\over2} A$
$A = 1 + {1\over 2} + {1\over 4} A + {1\over 2} A$
$A = 6$



The expected number of flips to get HH is 6.


Case 2: Waiting for HT


$A$ = average nb. of flips to get HT after T or nothing.
$B$ = average nb. of flips to get HT after H.


A is 1 flip, plus B if you get H and continue, or plus A if you get T and restart:
$A = 1 + {1\over2}B + {1\over2}A$


B is 1 flip, and you are done if you get T, or plus B if you get H and wait for T again:
$B = 1 + {1\over 2}0 + {1\over 2}B$


This resolves to:
$B = 1 + {1\over 2}B$

$B = 2$
$A = 1 + {1\over 2}2 + {1\over 2}A = 2 + {1\over 2}A$
$A = 4$


The expected number of flips to get HT is 4.


Comparison


The difference comes from the fact that in the first case, if you get the wrong 2nd result, you start all over, while in the second case you continue with one good result.


No comments:

Post a Comment

Understanding Stagnation point in pitot fluid

What is stagnation point in fluid mechanics. At the open end of the pitot tube the velocity of the fluid becomes zero.But that should result...