# Probability Distribution of Runs in Coin Flips

If you flip a coin $n$ times, what is the probability distribution of the longest "run" (sequence of consecutive heads or tails) which will occur? Or if that's not possible, what is the average?

I have tried everything I know of and have never been able to solve this... I wondered if someone would have any ideas.

I'm assuming the answer to this is known - it is related to the iconic "stats magic trick" where the professor tells which sequences of coin flips are real and which are human-created by looking at the length of the longest run (humans naturally switch too often).

As my "contribution" here are some computer simulations that got the average for the first few $n$ flips (I averaged over 100,000 trials): $$\begin{cases}n=1&1.0\\n=2&1.49856\\n=3&2.00221 \\n=4&2.37459 \\n=5&2.6846 \\n=10&3.66115 \\n=50&5.97501 \\n=200&7.98442 \end{cases}$$

Clarification: Given $n$ flips of a fair coin, what is the probability that the longest run is of length $k$? And (if that has no closed form) what is the average longest run?

• Basically the same as this question: math.stackexchange.com/questions/59738/… Apr 11, 2014 at 1:38
• @mjqxxxx Well I guess that explains why I didn't derive the formula myself :)... what should I do with this question then? Delete it?
– user142299
Apr 11, 2014 at 1:43

I'm not too sure if this is what you're looking for, but given that your asking for the 'longest run' in $n$ flips, well, the longest possible run in $n$ flips would be a run of $n$.

Then this will have a probability of $$P = \left(\frac{1}{2}\right)^{n-1}$$

since you don't mind what you get on the first flip, and then the probability is 1/2 for each flip thenceforth.

• I am wanting to know how likely it will be to have the longest run be of size $k$ in $n$ flips.
– user142299
Apr 11, 2014 at 1:27

Your question is a bit unclear to me, but if you are looking for finding the expected longest run, $$r$$ in a trial length of $$n$$ and the probability for success is $$p$$ is $$0.5$$, then it is:

$$\dfrac{\log(\frac{1}{n})}{\log(0.5)}= E$$ (longest run) and as the standard deviation is rather constant, you can give and take $$\pm2.$$(Schilling).

$$1000$$ flips and $$p=0.5$$ will give an estimated longest run of $$9.96$$ and $$1024$$ flips will yield 10. Note that $$2^{10}=1024$$ and $$2^x = 1024$$ and try and solve that equation. $$x \log(2)=\log(1024)$$ and $$x = \dfrac{\log(1024)}{\log(2)} = 10$$. Schilling just got around a problem of negative sings by rewriting it into $$\dfrac{\log(\frac{1}{1024})}{\log(0.5)}$$ which is the same as $$\dfrac{\log(\frac{1}{1024})}{\log(\frac{1}{2})}$$.

It is practically useful in i.e. the currency market, where $$1.000$$ trading minutes will show the same pattern for moves up and down like a coin flip of $$1.000$$ trials. But it always gives discussions because there are traders who mistake it and interpret it as if they are in a Casino game, which is not the case, but that discussion will go too far.