4
$\begingroup$

I found this puzzle online. Before my question gets flagged or on hold, I know the question has already been answered here but since I tried to solve it on my own I want to check if it's correct or not.

The puzzle is "What is the expected Number of Coin Tosses to Get Five Consecutive Heads".

My answer is the following:

Because a coin has two sides, one for tails and one for heads, let $p$ be the probability of getting heads. Then the probability of getting tails is $1-p$. For obvious reasons I shall assume that the coin is fair, thus the probability of getting heads is $\dfrac{1}{2}$ and tails $\dfrac{1}{2}$ as well.

Let $X_i$ be a random variable indicating the number of flips required to get heads, when $i-1$ was heads.

What we are looking for is the number of tries for a single success, thus we shall assume the random variable $X_i$ is following the Geometric Distribution with Probability $P(X_i = x) = p (1-p)^{x-1}$.

The expected number of coin flips to get 5 consecutive heads is given by the expected average $E(X) = \dfrac{1}{p}$.

The probability of the random variable $X_i$ is $\dfrac{1}{2^{i}}$ since the coin is fair.

Thus for $5$ consecutive heads $E(X) = E(X_1) + ... + E(X_5) = \sum_{i=1}^{5}E(X_i) = \sum_{i=1}^{5}2^i = 62$

So the expected number of coin flips to get $5$ consecutive heads is $62$.

$\endgroup$
  • $\begingroup$ Just for fun I simulated this in excel, using all of the columns except 1 for 16,383 samples for each simulation. The rows were the coin flips. After a few recalculations the averages of the 16,383 runs were: 61.41469816, 62.28999573, 61.48391625, 61.73258866, 62.85423915. It seems to support your answer. $\endgroup$ – Mitchell Kaplan Jun 24 '15 at 16:55
  • $\begingroup$ @MitchellKaplan I'm curious, how can you run a simulation in excel? I thought probability simulations were written in R. $\endgroup$ – Rrjrjtlokrthjji Jun 24 '15 at 16:59
  • 2
    $\begingroup$ Excel has a Rand() function, which returns a uniform random number X, with 0<=X<1. In sheet1, cell A1 contains Rand()<.5. I decided that a result of TRUE is heads, and FALSE is tails. Copy this down for about 1,000 rows. On sheet2, cell A5 put the following formula: AND(Sheet1!A1:A5). So if cells A1-A5 (on sheet1) are all "heads", then the value of A5 on sheet 2 will be TRUE. Copy this formula (on sheet2) down for 1,000 rows. Now you have to find out where the first TRUE occurs in that column of sheet 2. I'm running out of room here. Copy this to other columns. Hit F9 to do a recalc $\endgroup$ – Mitchell Kaplan Jun 24 '15 at 17:48
  • $\begingroup$ I tried to understand the definition of your $X_i$ but I failed. Could you explain again? I didi't understand what you meant by "probability of the random variable $X_i$." $\endgroup$ – Rodrigo Ribeiro Jun 24 '15 at 23:01
  • $\begingroup$ @RodrigoRibeiro pardon my math terms but English isn't my first language. I defined $X_i$ as the random variable showing the number of coin flips to get head , when the previous flip $i-1$ was heads. At the probability of the random variable I meant because the flips are independent, to get $k$ consecutive heads the probability is $\frac{1}{2^k}$. $\endgroup$ – Rrjrjtlokrthjji Jun 24 '15 at 23:09
4
$\begingroup$

I ask you for additional explanation. Meanwhile I'll post here another approach.

Denote by $\tau_i^5$ the random variable that counts the time required to get five heads starting from $i$ heads, ok?

What we want is exactly $E[\tau_0^5]$, right?

Now, you can evaluate $E[\tau_0^5]$ conditioning at the first step.

$$ E[\tau_0^5] = \frac{E[\tau_0^5]}{2} + \frac{E[\tau_1^5]}{2} +1 $$

Explaining the equation above. With probability $1/2$ you have a tail, so the time you will take to get five heads is the same, because you have any heads. On the other hand, with the same probability you get a head, and now, the number of flips needed to get 5 heads is $E[\tau_1^5]$, because now you that you have one head. The +1 it is because you have to count the first step.

Repeating the argument above you get

$$ E[\tau_1^5] = \frac{E[\tau_0^5]}{2} + \frac{E[\tau_2^5]}{2} +1 $$

Proceeding this way, and remembering $E[\tau_5^5]=0$, you get

$$ E[\tau_0^5] = 62 $$

This may seems more complicated at the first sight, but the idea of "to conditionate at what happens at the first time (or movement)" solve a big variety of problems.

$\endgroup$
  • $\begingroup$ Thanks for your alternative answer! I will take a look at it in detail tomorrow because it's very late. Any suggested readings on recursive techniques in probabilistic problems? $\endgroup$ – Rrjrjtlokrthjji Jun 24 '15 at 23:19
  • $\begingroup$ Well, I see this kind of solution, usually, in problems involving Discrete Markov Chains. The Gambler's ruin, the first run of three sixes, the secretary problem are classical problems of the subject. $\endgroup$ – Rodrigo Ribeiro Jun 24 '15 at 23:23
  • $\begingroup$ Thanks, I'm aware of Markov Chains, will look more in depth. Have a great night! $\endgroup$ – Rrjrjtlokrthjji Jun 24 '15 at 23:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.