1

In particular, I'm supposed to derive the following recurrence relation: $$Q_n = \frac{1}{2}Q_{n-1}+\frac{1}{4}Q_{n-2}+\frac{1}{8}Q_{n-3}$$

where $Q_0=Q_1=Q_2=1$ and $Q_n$ represents the probability that we don't have $3$ consecutive heads in $n$ tosses?

Note: this is a tutorial problem (not homework) and I was given a derivation of the recurrence relation but I think it's wrong. I'm trying to find a solution myself...

Jimmy R.
  • 36,148

2 Answers2

2

Partition all sequences $S_n$ of $n>2$ tosses into the following disjoint subsets:

  • $S_{HHH}$, ending in $HHH$. Note that $\mid S_{HHH}\! \mid\,=\frac{\mid S_n\mid}{8}$. These avoid $HHH$ with probability $0$.
  • $S_{THH}$, ending in $THH$. Note that $\mid S_{THH}\! \mid\,=\frac{\mid S_n\mid}{8}$. These avoid $HHH$ with probability $Q_{n-3}$.
  • $S_{TH}$, ending in $TH$. Note that $\mid S_{TH}\! \mid\,=\frac{\mid S_n\mid}{4}$. These avoid $HHH$ with probability $Q_{n-2}$.
  • $S_{T}$, ending in $T$. Note that $\mid S_{T}\! \mid\,=\frac{\mid S_n\mid}{2}$. These avoid $HHH$ with probability $Q_{n-1}$.

By the law of total probability, the probability that a sequence in $S_n$ avoids $HHH$ is $$\frac{0}{8}+\frac{Q_{n-3}}{8}+\frac{Q_{n-2}}{4}+\frac{Q_{n-1}}{2}.$$

Steve Kass
  • 15,314
1

We can also derive an explicit formula of the probability based upon the Goulden-Jackson Cluster Method.

We consider the set of words $\mathcal{V}^{\star}$ of length $n\geq 0$ built from an alphabet $$\mathcal{V}=\{H,T\}$$ and the bad word $HHH$ which is not allowed to be part of the words we are looking for. We derive a function $f(s)$ with the coefficient of $s^n$ being the number of wanted words of length $n$.

According to the paper (p.7) from Goulden and Jackson the generating function $f(s)$ is \begin{align*} f(s)=\frac{1}{1-ds-\text{weight}(\mathcal{C})}\tag{1} \end{align*} with $d=|\mathcal{V}|=2$, the size of the alphabet and with the weight-numerator $\mathcal{C}$ with \begin{align*} \text{weight}(\mathcal{C})=\text{weight}(\mathcal{C}[HHH]) \end{align*} We calculate according to the paper \begin{align*} \text{weight}(\mathcal{C}[HHH])&=-\frac{s^3}{1+s+s^2}=-\frac{s^3(1-s)}{1-s^3} \end{align*}

We obtain the generating function $f(s)$ for the words built from $\{H,T\}$ which don't contain the substring $HHH$ as \begin{align*} f(s)&=\frac{1}{1-2s+\frac{s^3(1-s)}{1-s^3}}\\ &=\frac{1-s^3}{1-2s+s^4}\tag{2}\\ &=1+2s+4s^2+7s^3+13s^4+24s^5+44s^6+81s^7+\cdots \end{align*}

The wanted probability is accordingly \begin{align*} \frac{[s^n]f(s)}{2^n}\qquad\qquad n\geq 0 \end{align*}

We obtain e.g. using OPs recursion formula: \begin{align*} Q_3=\frac{1}{2}\cdot 1+\frac{1}{4}\cdot 1+\frac{1}{8}\cdot 1=\frac{7}{8}\quad\text{and}\quad Q_4=\frac{1}{2}\cdot \frac{7}{8}+\frac{1}{4}\cdot 1+\frac{1}{8}=\frac{13}{16} \end{align*} correponding to $\frac{[s^3]f(s)}{2^3}$ and $\frac{[s^4]f(s)}{2^4}$.

Note: The entries in the sequence $(1,2,4,7,13,24,44,81,149,274,\ldots)$ are the so-called Tribonacci numbers stored as A000073 in OEIS.

We use the series representation of $f(s)$ in (2) to derive an explicit formula for the Tribonacci numbers.

\begin{align*} [s^n]f(s)&=[s^n](1-s^3)\sum_{k=0}^{\infty}(2s-s^4)^k\\ &=[s^n](1-s^3)\sum_{k=0}^{\infty}s^k(2-s^3)^k\\ &=[s^n](1-s^3)\sum_{k=0}^{\infty}s^k\sum_{j=0}^k\binom{k}{j}(-1)^js^{3j}2^{k-j}\\ &=([s^n]-[s^{n-3}])\sum_{k=0}^{\infty}s^k\sum_{j=0}^k\binom{k}{j}(-1)^js^{3j}2^{k-j}\tag{3}\\ &=\sum_{k=0}^{n}([s^{n-k}]-[s^{n-3-k}])\sum_{j=0}^k\binom{k}{j}(-1)^js^{3j}2^{k-j}\tag{4}\\ &=\sum_{{k=0}\atop{k\equiv n(\bmod 3)}}^{n}\binom{k}{\frac{n-k}{3}}(-1)^{\frac{n-k}{3}}2^{k-\frac{n-k}{3}}\\ &\qquad-\sum_{{k=0}\atop{k\equiv n(\bmod 3)}}^{n-3}\binom{k}{\frac{n-k}{3}-1}(-1)^{\frac{n-k}{3}-1}2^{k-\frac{n-k}{3}+1}\\ &=\sum_{{k=0}\atop{k\equiv n(\bmod 3)}}^{2}\binom{k}{\frac{n-k}{3}}(-1)^{\frac{n-k}{3}}2^{k-\frac{n-k}{3}}\tag{5}\\ &\qquad+\sum_{{k=3}\atop{k\equiv n(\bmod 3)}}^{n-3} \left(\binom{k}{\frac{n-k}{3}}-\frac{1}{8}\binom{k-3}{\frac{n-k}{3}}\right)(-1)^{\frac{n-k}{3}}2^{k-\frac{n-k}{3}}\\ \end{align*}

Comment:

  • In (3) we use the linearity of the coefficient of operator and $[s^n]s^kf(s)=[s^{n-k}]f(s)$

  • In (4) we change the limit of the left hand sum from $\infty$ to $n$ according to the maximum coefficient $[s^n]$. According to the factors $s^{3j}$ we consider in the following only summands with $k\equiv n(\bmod 3)$

  • In (5) we reorganise the sums from the line above by extracting from the left hand sum the first summand and shifting in the right hand side the index by one and putting both sums together.

We conclude: An explicit representation of the probability $Q_n$ $(n\geq 0)$ is according to (5) \begin{align*} Q_n&=\sum_{{k=0}\atop{k\equiv n(\bmod 3)}}^{2}\binom{k}{\frac{n-k}{3}}(-1)^{\frac{n-k}{3}}2^{-\frac{4(n-k)}{3}}\\ &\qquad+\sum_{{k=3}\atop{k\equiv n(\bmod 3)}}^{n-3} \left(\binom{k}{\frac{n-k}{3}}-\frac{1}{8}\binom{k-3}{\frac{n-k}{3}}\right)(-1)^{\frac{n-k}{3}}2^{-\frac{4(n-k)}{3}} \end{align*}

Markus Scheuer
  • 112,413