5

If a coin is flipped 25 times with eight tails occurring, what is the probability that no run of six (or more) consecutive heads occur?

Wasn't sure how to approach this and am quite positive my generating function is incorrect. My attempted work:

Consider $e_H,e_T$ s.t $e_H$ denotes the number of times our coin lands on heads and $e_T$ is the number of times our coin lands on tails. We want the number of integer solutions to: $$e_H+e_T=25$$ where $e_H \in [9,25]$ and $e_T=8$. It follows that our generating function $h$ is $$h(x)=(x^9+x^{10}+...x^{25})x^8$$ where we want to find the coefficient of $x^{25}$.

Now, observe that $h$ can re-written as $$h(x)=x^{17}(1+x+...x^{16})$$ where we want to find the coefficient of $x^{16}$ now. Using the formula for finite geometric series, we see that $h$ becomes $$h(x)=x^{17}(\frac{1-x^{17}}{1-x})$$ $$=x^{17}(1-x^{17})(\frac{1}{1-x})$$ where using the formula for infinite geometric series gives us $$x^{17}(1-x^{17})(1+x+...+x^n+...)$$ Finally, using the formula $h(x)=f(x)g(x)=c_0 + c_1x+...+c_rx^r+...$ where $c_r=a_0b_r+a_1b_{r-1}+...a_rb_0$, we find $$f(x)=(1-x^{17}),g(x)=(1+x+...)$$ $$\implies a_0b_16=1*1=1$$ so it follows that the coefficient attached to $x^{16}$ is 1.

Can someone help lead me down the right path? If my work is actually correct, where do I proceed from here?

2 Answers2

5

I think the way you are attempting cannot take care of the consecutive heads.

Since there is an extra constraint of having exactly 8 tails, we need a bivariate generating function, which I think the easiest is to obtain the regular expression and convert that to a generating function (analytic combinatorics).

For $h$ heads and $t$ tails, the RE can be written as $$(t+h(t+h(t+h(t+h(t+ht)))))^*(\epsilon+h(\epsilon+h(\epsilon+h(\epsilon+h(\epsilon+h)))))$$

for which the corresponding gf is:

\begin{align*} G(h,t) &= \frac{1+h+h^2+h^3+h^4+h^5}{1-t\left(1+h+h^2+h^3+h^4+h^5\right)} \end{align*}

and the probability is

\begin{align*} \frac{1}{\binom{25}{8}}[t^8h^{17}]G(h,t) &= \frac{49741}{120175} \approx 0.413904722280008 \end{align*}

gar
  • 4,948
  • I've never seen this before. What exactly is $\epsilon$ denoting in this solution? – Savage Henry Jun 26 '14 at 04:43
  • E.g. $(\epsilon+h(\epsilon+h))=(\epsilon+h+hh)$, which tells us that the input can either be nothing, or a single h, or hh. And $h^*$ is short for $(\epsilon+h+hh+hhh+\cdots)$. See finite automata (DFA, NFA, minimizing DFA, conversion to RE etc.) for information. – gar Jun 26 '14 at 05:03
  • Oh whoa. I've not learned any of this yet. :( Your answer looks thorough, I just wish I was more familiar with the material. I've got to read more about this. I'm assuming the Analytical Combinatorics discusses this in depth? – Savage Henry Jun 26 '14 at 05:17
  • "Finite automata and formal languages" is usually taught in computer science courses (well, they do not mention how to apply it to combinatorics, sigh!). I recently came to know about it by reading that book. Many of the questions can be answered mechanically from the material discussed in the book. We may get overwhelmed on the first reading, though. Try to go through it when you are relaxed. – gar Jun 26 '14 at 05:28
  • Ah okay. Yeah I think I'll be able to find some time around the time of July 4th to really sink my teeth in to this. Probability is so very interesting, just soooooooo unintuitive so far. – Savage Henry Jun 26 '14 at 05:44
  • Okay. Interesting to me as well! Programming will also be of much help, which can verify our answer. – gar Jun 26 '14 at 05:54
  • @gar: Typo: Since your regep is $((\varepsilon+h+\dots+h^5)t)^*(\varepsilon+h+\dots+h^5)$ describing all words containing zero or more $t$s preceded by zero up to $5$ $h$s and each of these words ending with zero up to $5$ $h$s, the corresponding generating function is $G(h,t)=\frac{1+h+\dots+h^5}{1-t(1+h+\dots+h^5)}$ – Markus Scheuer Jun 30 '14 at 17:05
  • @gar: Minor: According to the wording in the question a coin is flipped $25$ times with eight tails occuring and also according to your coefficient $[t^8h^{17}]$ we consider only configurations with $8$ tails. So, the total number of events is $\binom{25}{8}$. The resulting probability is therefore $\frac{1}{\binom{25}{8}}[t^8h^{17}]G(h,t)=\frac{447669}{1081575}\simeq0.41$ in accordance with the approach of blue. I think the different results impressively show how difficult it is for us to develop some intuitive insight. – Markus Scheuer Jun 30 '14 at 17:08
  • @SavageHenry: A hint to link the answers/comments of user gar and user blue. If we write $u(x)=1+x+\dots+x^5$, then according to your comments with user blue you get: $h(x)=u^9(x)$. Now let's write $G(x,t)$ instead of $G(h,t)$ and we see that $G(x,t)=\frac{u(x)}{1-tu(x)}$.So, $[t^8x^{17}]G(x,t)=[t^8x^{17}]\frac{u(x)}{1-tu(x)}=[t^8x^{17}]\sum_{n\ge0}u^{n+1}(x)t^n=[x^{17}]u^9(x)=[x^{17}]h(x)$. The probability is therefore $\frac{1}{\binom{25}{8}}[t^8x^{17}]G(x,t)=\frac{1}{\binom{25}{8}}[t^8x^{17}]h(x)=\frac{447669}{1081575}\simeq0.41$. – Markus Scheuer Jun 30 '14 at 17:13
  • @SavageHenry: You comment just soooooooo unintuitive is also shared by famous experts :-) You might find my answer to the question 'Obvious' theorems that are actually false pleasing. – Markus Scheuer Jun 30 '14 at 17:14
  • @MarkusScheuer : Thanks for pointing it out, corrected both mistakes. – gar Jun 30 '14 at 17:53
  • @gar: You're welcome! – Markus Scheuer Jun 30 '14 at 18:02
3

You are not counting the integer solutions to $H+T=25$ with $T=8$. Quite obviously, that only has one solution. All that equation says is that the number of heads plus the number of tails is the total number of flips; that equation doesn't know anything about the different ways there are to arrange the flips in sequence without too many consecutive head flips.

Let $h_i$ be the number of heads between the $i$th and $(i+1)$th tail flip, for $i=0,\cdots,8$. (So $h_0$ is the number of heads that appear before the first tail flip, and $h_8$ the number after the last tail flip.) The numbers $(h_0,\cdots,h_8)$ determine the entire sequence of flips.

You're counting the number of $(h_0,\cdots,h_8)$ for which $h_0+\cdots+h_8=17$ and $0\le h_i\le 5$. Can you figure out the correct generating function to use now?

anon
  • 151,657
  • I think I understand. Why then did you choose to have $h_9$ if we're dealing with 0-8? Further, why does $h_i \in [0,5]$? Is that so we don't have more than 6 occurrences of heads? – Savage Henry Jun 26 '14 at 05:13
  • @SavageHenry (1) Typo, (2) Yes. – anon Jun 26 '14 at 05:13
  • Oh okay that makes a lot of sense then! I found the generating function to be $$h(x)=(1+x+x^2+x^3+x^4+x^5)^8.$$ So now all I have to do is find the coefficient to x^{17}. Another question, good sir: in order to find the total outcomes (without the restrictions imposed), would I simply have $$\frac{25!}{17!8!}?$$ I ask this just to be sure my logic is sound – Savage Henry Jun 26 '14 at 05:31
  • The answer to your latest question is yes, the total number of outcomes is $\binom{25}{8}$. The exponent on your generating function should be $9$ though. To find the coefficient of $x^{17}$, write $h(x)=(1-x^6)^9(1-x)^{-9}$, expand both of those binomials with the binomial expansion (the first will be an infinite series), ... – anon Jun 26 '14 at 05:35
  • Hmmm...why wouldn't in be to 8th degree? Since we have $$\sum_{i=1}^8 h_i = 17,$$ wouldn't our degree ultimately be 8 and not 9? – Savage Henry Jun 26 '14 at 05:42
  • @SavageHenry The lower index should start at $i=0$, not $i=1$. – anon Jun 26 '14 at 05:46
  • OOOOOOOOOOOH gotchya. Thanks for the catch. I had forgotten about $h_0$. Thanks for the help, my friend – Savage Henry Jun 26 '14 at 05:48