# Consecuitive Coin Flip Probability

What formula would someone use to calculate the probability of having $n$ consecutive heads out of $x$ flips, and what formula would it be if it were at least $n$ consecutive heads (with a fair coin) out of $x$ flips? I would think it would be something divided by $2^x$, but I don't know where to go from there.

• Is your first question asking for "probability of having only $n$ heads that are consecutive"? – user21820 Jan 8 '15 at 3:27
• Yes, whereas if n=3, then we would only consider the cases with four consecuituve flips in the second formula. – John Doey Jan 8 '15 at 3:29
• So you want $n$ consecutive heads flanked by tails in the first case. – user21820 Jan 8 '15 at 3:33
• Yes, but one side of the row of consecuitive heads may be open. Ex. HHHTH would qualify for the first case if n=3. – John Doey Jan 8 '15 at 3:37

For your first question we require $n$ heads out of $x$ flips. We can relate to the fundamental formula of probability to yield our answer. That is,

$$\mathcal{P}(\mathrm{n\ Consecutive\ Heads)}=\frac{\mathrm{Number\ of\ Favourable\ Outcomes}}{\mathrm{Number\ of\ Total\ Outcomes}}.$$

Now the number of total outcomes will be equal to $2^{x}$. To find the number of favourable outcomes, we have to talk about a couple of things. First, it should be clear that since we require $n$ consecutive heads, this is only possible when the "sequence" of heads start at the very latest, on the $(x-n+1)\mathrm{th}$ flip. Take an arbitrary example - say you flip the coin 5 times and want 2 consecutive heads - where is the latest flip that we can start?

The next thing to mention is that to ensure we only get $n$ consecutive heads, the outcome of the flips next to the sequence of heads must be tails!

This is all we have to consider. If we do get 2 sets of $n$ consecutive heads, it does not matter for our question. So lets begin the calculations.

Assume that our sequence of heads starts in the first position. Therefore, by the multiplication principle, the number of outcomes given our assumption is

$$\mathrm{Sequence}_{\mathrm{1st\ Position}}=([1\times 1...\times 1]\times1)\times 2\times 2\times ...\times 2.$$

In the square brackets we clearly want the outcomes to be head. Thus, only 1 possible outcome of a flip is possible, namely head. Immediately outside the square bracket we require a tail to ensure that the sequence of heads is strictly of "length" $n$. The rest of the multiplication can either be head or tail. But the question is, how many $2$'s are there? Well, out of the $x$ flips, $n$ went to the sequence of heads, and $1$ went to the tail. Therefore there must be $(x-n-1)$, $2$'s. Thus,

$$\mathrm{Sequence}_{\mathrm{1st\ Position}}= 2^{x-n-1)}.$$

By symmetry it should be clear that (recalling our LAST position for the sequence of heads to be at $x-n+1$

$$\mathrm{Sequence}_{\mathrm{(x-n+1)th\ Position}}= 2^{x-(n+1)}.$$

Finally, we have to consider the number of outcomes if the sequence of heads starts in positions that we have not covered. Well, this is a simple alternation as we require another tail on the side of the sequence. Therefore,

$$\mathrm{Sequence}_{\mathrm{ith\ Position}}= 2^{x-(n+2)},$$

where $i$ is a positive integer in $[2,x-n]$. Why $x-n$? Well $i$ is the value that is not at the first and last possible position that I mentioned earlier to be $x-n+1$. Therefore, the number of favourable outcomes is given by

$$\mathrm{Number\ of\ Favourable\ Outcomes} = 2^{x-(n+1)} +(x-n+1)2^{x-(n+2)}+2^{x-(n+1)}$$ $$=2^{x-n} + (x-n+1)2^{x-(n+2)}$$ $$=2^{x}2^{-n} + (x-n+1)2^{x}2^{-(n+2)}$$ $$=2^{x}[2^{-n} + (x-n+1)2^{-(n+2)}].$$

Therefore

$$\mathcal{P}(\mathrm{n\ Consecutive\ Heads)}=\frac{2^{x}[2^{-n} + (x-n+1)2^{-(n+2)}]}{2^{x}}.$$ $$=2^{-n} + (x-n+1)2^{-(n+2)}.$$

I encourage you to use the same problem solving process used here to solve your latter question.