# If I flip a coin $n$ times, what is the expected maximum number of heads or tails in a row?

Question: If I flip a coin $n$ times, what is the maximum number of heads or tails in a row that I should expect?

• – Tdonut May 7 '15 at 19:16
• As for the question of "flipping an infinite number of times," you seem to greatly misunderstand the meaning of infinity. What will be true is that with a fair coin and an "infinite" number of coinflips, that any finite-length sequence of heads/tails will appear in the sequence, such as a billion heads in a row. You cannot get an infinite string of heads however as that would contradict the notion that the coin is fair. See Normal Number. Such a sequence of heads/tails could help us create a binary normal number. – JMoravitz May 7 '15 at 19:20
• @JMoravitz "grossly" is a bit strong – Gregory Grant May 7 '15 at 19:21
• @JMoravitz: I cleaned up the question a bit as the part about an infinite number of flips does not seem well phrased. – Eric Naslund May 7 '15 at 19:23

Let $Z_0(n)$ be a random variable denoting the longest sequence of heads in a sequence of $n$ flips. In 1980, Guibas and Odlyzko showed that $$\mathbb{E}(Z_0(n)) = \log_2(n)+\frac{\gamma}{\log 2} -\frac{3}{2} +\rho_0(n)+o(1)$$ where $\gamma$ is the Euler-Mascheroni constant, and $\rho_0(n)$ is an osscilatory function of $\log (n)$ bounded in absolute value by $1.6\cdot10^{-6}$. In particular, this leads to the surprising result that $$\mathbb{E}(Z_0(n))-\log_2(n)$$ does not have a limit. See this paper, An Extreme Value Theory for Long Head Runs, by Gordon, Schilling, Waterman for more details.
• Reading the linked article, I am surprised that the variance is as low as it is, being of the form $\frac{\pi^2}{6\log_2(n)}+\frac{1}{12}+\rho_0(n)+o(1)$. Perhaps you can confirm what I'm thinking or missing from reading the article, with a fair coin, the expected longest sequence of heads tends towards the expected longest sequence of just heads or just tails, yes? – JMoravitz May 7 '15 at 19:53
• How can one prove $\mathbb{E}(Z_0(n)) = \log_2(n)+o(\log_2(n))$ elementarily ? – Gabriel Romon May 7 '15 at 20:04