1
$\begingroup$

So a run of $x$ heads has the probability $0.5^x$. Thefore a run of $9$ would be $0.5^9 = 0.001953125$.

But what is the chance of that run of $9$ occuring in $1000$ coinflips? Can anyone please explain how to work this out?

  • 0
    Know the concept of https://en.wikipedia.org/wiki/Binomial_distribution?2017-02-15
  • 0
    Do you need consecutive 9 heads in 1000 flips OR just 9 heads in any place in 1000 flips?2017-02-15
  • 0
    Binomial distribution won't get you there. He wants 9 flips in a row to be heads when flipping a coin 1000. Not the same as getting exactly 9 heads in 1000 flips which the binomial distribution would give you the answer to.2017-02-15
  • 0
    Exactly as Laars says. The chances of a 9 head run happening at least once.2017-02-15
  • 2
    Is this what you're looking for? http://wangling.me/2008/09/the-probability-of-runs-of-k-consecutive-heads-in-n-coin-tosses.html2017-02-15
  • 0
    You can get an estimate by considering nine consecutive starting at an index divisible by 9. If this value is low enough, multiplying it by 9 should provide a good estimate.2017-02-15

1 Answers 1

2

Here is an answer based upon generating functions. We start with a generating function for words of a two character alphabet $V=\{T,H\}$ which counts words with no consecutive equal characters at all.

These words are called Smirnov or Carlitz words. See example III.24 Smirnov words from Analytic Combinatorics by Philippe Flajolet and Robert Sedgewick for more information. (You might also find this answer helpful.)

The generating function $A(z)$ counting Smirnov words over a two character alphabet is according to the reference \begin{align*} A(z)=\left(1-\frac{2z}{1+z}\right)^{-1} \end{align*}

The coefficient of $z^n$ of $A(z)$ gives the number of Smirnov words of length $n$, i.e. the number of words with no consecutive equal heads and tails.

Since there is no restriction to the distribution of tails, we can replace each character "T" in a Smirnov word by one or more "T"s, which means to replace \begin{align*} z\longrightarrow z+z^2+z^3+\cdots=\color{blue}{\frac{z}{1-z}} \end{align*} in the corresponding generating function $A(z)$.

Based upon $A(z)$ we obtain this way a generating function $B(z)$ with \begin{align*} B(z)&=\left(1-\frac{z}{1+z}-\frac{\color{blue}{\frac{z}{1-z}}}{1+\color{blue}{\frac{z}{1-z}}}\right)^{-1}\\ &=\left(1-\frac{z}{1+z}-z\right)^{-1}\\ \end{align*}

The coefficient of $z^n$ of $B(z)$ gives the number of words of length $n$ with no consecutive equal heads.

We next allow a distribution of heads with runs up to length $8$. This implies a replacement of each character "H" by one up to eight "H"s, which means \begin{align*} z\longrightarrow z+z^2+z^3+\cdots+z^8=\frac{z(1-z^8)}{1-z} \end{align*}

Based upon $B(z)$ we obtain this way a generating function $C(z)$ with \begin{align*} C(z)&=\left(1-\frac{\color{blue}{\frac{z(1-z^8)}{1-z}}}{1+\color{blue}{\frac{z(1-z^8)}{1-z}}}-z\right)^{-1}\\ &=\frac{(1+z+z^2)(1+z^3+z^6)}{1-z+z^2+z^3+z^4+z^5+z^6+z^7+z^8+z^9} \end{align*}

The coefficient of $z^n$ of $C(z)$ gives the number of words of length $n$ having no runs of heads of length $9$.

Finally in order to get the number of all words of length $n$ which have a run of heads of length $9$, we take all words and subtract those counted by $C(z)$.

We obtain \begin{align*} D(z)&=\frac{1}{1-2z}-C(z)\\ &=\frac{z^9}{(1-2z)(1-z+z^2+z^3+z^4+z^5+z^6+z^7+z^8+z^9)}\\ &=z^9+3z^{10}+\color{blue}{8}z^{11}+20z^{12}+48z^{13}+112z^{14}+\cdots\tag{1} \end{align*}

whereby the last line was obtained with some help of Wolfram Alpha.

We observe (blue marked coefficient) in (1) there are $8$ words of length $11$ having a run of (at least) $9$ consecutive heads. These are

\begin{array}{ccc} HHHHHHHHH\color{blue}{TT}&HHHHHHHHH\color{blue}{HT}&HHHHHHHHH\color{blue}{HH}\\ \color{blue}{T}HHHHHHHHH\color{blue}{T}&HHHHHHHHH\color{blue}{TH}\\ \color{blue}{TT}HHHHHHHHH&\color{blue}{T}HHHHHHHHH\color{blue}{H}\\ &\color{blue}{HT}HHHHHHHHH\\ \end{array}

The probability of runs of heads of length $9$ in sequences of $10,100$ and $1000$ coin flips is according to WA \begin{align*} 2^{-10}\cdot[z^{10}]D(z)&=\frac{3}{1024}\doteq 0.00292969\\ 2^{-100}\cdot[z^{100}]D(z)&\doteq 0.0875589\\ 2^{-1000}\cdot[z^{1000}]D(z)&\doteq 0.624241\\ \end{align*}

  • 0
    This is super interesting, thank you!2017-02-15
  • 0
    @ElwoodP: You're welcome! Good to see the answer is useful. :-)2017-02-15
  • 0
    @MarkusScheuer Great answer. Unfortunately it hasn´t be read as many times as it should be. Aside from this I have a question: How did you get from this expression $\frac{z^9}{(1-2z)(1-z+z^2+z^3+z^4+z^5+z^6+z^7+z^8+z^9)}$ to the next line? Thanks in advance for your comment / answer.2018-01-20
  • 0
    @callculus: Thanks for your nice comment. At *[Wolfram.Alpha](http://m.wolframalpha.com)* I've typed *Series at $x=0$* in order to get the series expansion. Manually you would probably do long polynomial division to determine the first few coefficients.2018-01-21