0

What is the expected value of the longest run of heads or tails observed in $N$ flips of a fair coin?

I'd like to consider this for any $N$, small or large.

gb4
  • 93
  • Please write your problem specifically, instead of pasting links. – sam wolfe Dec 05 '19 at 20:23
  • A very similar question with an accepted answer about the expected longest run of heads (instead of heads or tails): https://math.stackexchange.com/questions/1409372 – joriki Dec 05 '19 at 20:28
  • Thank you, I have had a look at that post, however, I am not sure how to generalise it to consider heads or tails. – gb4 Dec 05 '19 at 20:30

1 Answers1

1

Following the approach suggested in What is the expected length of the largest run of heads if we make 1,000 flips?, we expect $N_k=2n(1-p)p^k=n\left(\frac12\right)^k$ runs of heads or tails of length $\ge k$ (twice as many as if we only counted runs of heads). So a rough estimate of the expected maximum length is the solution for $k$ of $N_k=n\left(\frac12\right)^k=1$, which is $k=\log_2n$. Thus, the expected length is roughly the same as if we only count runs of heads, just $\log_22=1$ more.

Here's code that simulates this difference. For $n=1000$, the difference is about $0.998$, in good agreement with the approximation. Thus, you can basically use the answers to the above question and add $1$.

joriki
  • 238,052