1

I posted this question here about finding the probability function for the number of flips needed to get 5 consecutive heads :(Probability Generating Functions for Coin Flip Problems?).

A user on math stackexchange posted the following answer involving Probability Generator Functions:

$$G_0(z) = pz G_1(z) + (1 - p) z G_0(z)$$ $$G_1(z) = pz G_2(z) + (1 -p) z G_0(z)$$ $$G_2(z) = pz G_3(z) + (1 - p) z G_0(z)$$ $$G_3(z) = pz G_4(z) +(1 - p) z G_0(z)$$ $$G_4(z) = pz + (1 - p) z G_0(z).$$

$$\begin{bmatrix} G_0(z) \\ G_1(z) \\ G_2(z) \\ G_3(z) \\ G_4(z) \end{bmatrix} = \begin{bmatrix} 0 \\ 0 \\ 0 \\ 0 \\ zp \end{bmatrix} + \begin{bmatrix} z(1 - p) & zp & 0 & 0 & 0 \\ z(1 - p) & 0 & zp & 0 & 0 \\ z(1 - p) & 0 & 0 & zp & 0 \\ z(1 - p) & 0 & 0 & 0 & zp \\ z(1 - p) & 0 & 0 & 0 & 0 \end{bmatrix} \begin{bmatrix} G_0(z) \\ G_1(z) \\ G_2(z) \\ G_3(z) \\ G_4(z) \end{bmatrix}$$

$$\left( I- z P \right) G(z) = zv$$

$$P = \begin{bmatrix} 1 - p & p & 0 & 0 & 0 \\ 1 - p & 0 & p & 0 & 0 \\ 1 - p & 0 & 0 & p & 0 \\ 1 - p & 0 & 0 & 0 & p \\ 1 - p & 0 & 0 & 0 & 0 \end{bmatrix}, v = \begin{bmatrix} 0 \\ 0 \\ 0 \\ 0 \\ p \end{bmatrix}$$

$$\boxed{ G(z) = (I - zP)^{-1} zv = \left( \sum_{k \ge 0} z^{k+1} P^k \right) v }.$$

In the answer, it was suggested to use Cramer's Rule to compute the inverse to find the probability function.

Here is my attempt:

$$A\mathbf{x} = \mathbf{b}$$ $$x_i = \frac{\det(A_i)}{\det(A)}$$ $$A_i = [a_1 \; a_2 \; \cdots \; b \; \cdots \; a_n]$$

$$\det(I - zP)$$: $$I - zP = \begin{bmatrix} 1-z(1-p) & -zp & 0 & 0 & 0 \\ -z(1-p) & 1 & -zp & 0 & 0 \\ -z(1-p) & 0 & 1 & -zp & 0 \\ -z(1-p) & 0 & 0 & 1 & -zp \\ -z(1-p) & 0 & 0 & 0 & 1 \end{bmatrix}$$

But I am feeling lost and don't know how to continue.

Can someone please show me how to do this?

Thanks

GBmath
  • 812
konofoso
  • 681
  • So you need to compute the determinant of $I-P$, and also the determinants of each of the five matrices you get by replacing the columns one by one with the vector $zv$. So what is the problem? – ancient mathematician Aug 21 '24 at 09:12
  • I am disinclined to write an answer to what is a purely mechanical computation. But here is a hint. First write $\alpha:=zp$ and $\beta:=z(1-p)$. Now input your matrix $(I-P)$ into the free online Wolfram Matrix Inverter. Apply the answer matrix to $(0,0,0,0,\alpha)$. Replace $\alpha, \beta$ by $zp, z(1-p)$ and you're done. – ancient mathematician Aug 21 '24 at 14:52
  • 1
    see https://www.wolframalpha.com/input?i2d=true&i=inv%7B%7B1-B%2C-A%2C0%2C0%2C0%7D%2C%7B-B%2C1%2C-A%2C0%2C0%7D%2C%7B-B%2C0%2C1%2C-A%2C0%7D%2C%7B-B%2C0%2C0%2C1%2C-A%7D%2C%7B-B%2C0%2C0%2C0%2C1%7D%7D – ancient mathematician Aug 21 '24 at 14:52

1 Answers1

1

Because we only need $G_0(z)$ and because $v$ has all zeros except the last element, all we need is just the top-right element of $(I-zP)^{-1}$, which can be found through block-wise inversion without worrying about other blocks in the inverse.

Define $A$, $B$, $C$ and $D$ as submatrices in $$I - zP =\left[ \begin{array}{c|cccc} 1-z(1-p) & -zp & 0 & 0 & 0 \\\hline -z(1-p) & 1 & -zp & 0 & 0 \\ -z(1-p) & 0 & 1 & -zp & 0 \\ -z(1-p) & 0 & 0 & 1 & -zp \\ -z(1-p) & 0 & 0 & 0 & 1 \end{array}\right]=:\left[\begin{array}{c|c} A & B\\\hline C&D \end{array}\right].$$ The top-right block of $(I-zP)^{-1}$ is then $-(A-BD^{-1}C)^{-1} BD^{-1}$, and so $G_0(z)=-(A-BD^{-1}C)^{-1} BD^{-1}(zv_{-1})$ where $v_{-1}$ denotes the vector $v$ without its first element.

$D$ has an upper triangular inverse $$D^{-1}=\begin{bmatrix}1 & zp & (zp)^2 & (zp)^3 \\0&1 & zp & (zp)^2\\ 0& 0&1 & zp \\ 0& 0& 0&1 \end{bmatrix}.$$ So $BD^{-1}C=z(1-p)\sum_{k=1}^4(zp)^k$ and $BD^{-1}(zv_{-1})=-(zp)^5$. It follows that
$$ G_0(z)=\frac{p^5 z^5}{1-(1-p)\sum_{k=0}^4 p^k z^{k+1}}. $$

As a check, we can expand $G_0(z)$ for a few terms, $$G_0(z)=p^5 z^5+(1-p) p^5 \sum_{k=6}^{10}z^k + p^5\left(1-p-p^5+p^6\right) z^{11} + \cdots $$ which confirms that

  1. the probability of hitting time 5 is $p^5$;
  2. for hitting times $6$ through $10$, the last 6 flips have to be THHHHH with probability $(1-p)p^5$ and there are no constraints except for the last 6 flips;
  3. starting from hitting time $11$, extra constraints on earlier flips apply to avoid $5$ consecutive H's, and thus the probability starts to be less than $(1-p)p^5$.

Also the mode is at 5, the probability masses never increases, and the expected value is $$G_0'(1)=\sum_{k=0}^4 p^{k-5}. $$

Zack Fisher
  • 2,481