Waiting time for a pattern in coin tossing Let $\{X_t\}$ be an iid sequence of fair coin tosses and $\tau_{HTH} = \inf\{t\geq 3: X_{t-2}X_{t-1}X_t=HTH\}$. I want to determine $E\tau_{HTH}$.
I don't understand a part of the explanation which is:
Gamblers place bets on each individual toss. On each bet, gambler pays an entrance fee of $k$ and is paid $2k$ in return if the outcome is $H$ or $0$ if the outcome is $T$. $k$ can be negative which corresponds to a bet on $T$.
Suppose that at each unit of time until $HTH$ first appears, a new gambler enters and employs the following strategy: on his first bet, he wagers $1$ on $H$. If he loses, he stops. If he wins and $HTH$ has not yet appeared, he wagers his payoff of $2$ on $T$. If he loses, he stops. If he wins and $HTH$ has not yet appeared, he wagers his payoff of $4$ on $H$. This is the last bet placed bu this particular gambler.
The gambler who started at $\tau_{HTH}$ is paid $2$ and the gambler who started at $\tau_{HTH}-2$ is paid $8$ and every gambler has paid an initial entry fee of $1$. At time $\tau_{HTH}$, the net profit to all gamblers $=10-\tau_{HTH}$ and since the game is fair $E\tau_{HTH}=10$

Q1) I can see that the net profit for all gamblers is $10-\tau_{HTH}$ if the outcome string is say $TTTHTH$ and this wouldn't be the net profit if atleast one $H$ appears before $HTH$, am I correct? (say the outcome string is $HHHHTH$).
Q2) The explanation also says $\tau_{HTH}/3$ is bounded by a Geometric(1/8) random variable. How can I see that?


We can handle the case of a possibly unfair coin using generating functions.
A pattern for all sequences ending in $HTH$ is
$$
T^\ast\left(H^\ast(HTT)T^\ast\right)^\ast H^\ast HTH\tag1
$$
where $(\dots)^\ast$ represents $0$ or more sequences matching $(\dots)$.
The generating function for $(1)$ is
$$
\overbrace{\ \frac1{1-qx}\ }^{T^\ast}\overbrace{\frac1{1-\underbrace{\frac1{1-px}pq^2x^3\frac1{1-qx}}_{H^\ast(HTT)T^\ast}}}^{\left(H^\ast(HTT)T^\ast\right)^\ast}\overbrace{\ \frac1{1-px}\ }^{H^\ast}\overbrace{\ \ p^2qx^3\ \ \vphantom{\frac11}}^{HTH}\tag2
$$
where $p$ is the probability of an $H$ and $q=1-p$ is the probability of a $T$.
That is,
$$
\begin{align}
g(x)
&=\frac{p^2(1-p)x^3}{1-x+p(1-p)x^2-p(1-p)^2x^3}\tag3\\[9pt]
g(1)
&=1\tag4\\[9pt]
%g'(x)
%&=\frac{p^2(1-p)x^2\left(3-2x+p(1-p)x^2\right)}{\left(1-x+p(1-p)x^2-p(1-p)^2x^3\right)^2}\\
g'(1)
&=\frac{1+p(1-p)}{p^2(1-p)}\tag5\\[3pt]
%g''(x)
%&=\frac{2p^2(1-p)x\left(3-3x+\left(1-p+p^2\right)x^2+6p(1-p)^2x^3-3p(1-p)^2x^4+p^2(1-p)^3x^5\right)}{\left(1-x+p(1-p)x^2-p(1-p)^2x^3\right)^3}\\
g''(1)
&=\frac{2+4p-8p^2+6p^4-2p^5}{p^4(1-p)^2}\tag6
\end{align}
$$
The mean duration is
$$
g'(1)=\frac{1+p(1-p)}{p^2(1-p)}\,\overset{p\to\frac12}\to\,10\tag7
$$
The duration variance is
$$
g''(1)+g'(1)-g'(1)^2=\frac{1+p(1-p)\left(2-4p-2p^2+p^3\right)}{p^4(1-p)^2}\,\overset{p\to\frac12}\to\,58\tag8
$$
