I am working on a probability question where I am to find the expected number of tosses to achieve the following pattern:
HTTTTTTTT...... (k-consecutive Tails (T))
I made this answer as the base case to solve this problem:
Let e be the expected number of toss. Following the logic in answer, let's say we get a Tail (T) immediately after starting the experiment. So the expected number would increase by 1 since we really need a Head before Tail. So the expected number would be $(e+1)$ with a probability of $\frac{1}{2}$...
Similarly if I get Head (H) followed by another Head (H) then expected number would still be $(e+1)$ with probability of $\frac{1}{2}$ ... and so one.
The equation that a derived is something like this:
$$e = \frac{1}{2}(e+1)+\frac{1}{4}(e+2)+\frac{1}{8}(e+3)+...+\frac{1}{2^{k+1}}(e+k+1)+\frac{1}{2^{k+1}}(k)$$
and after solving the above for $e$ I go a nice little final form as:
$$e = 3*(2^{k+1} - (k+2))$$
Can someone comment on the accuracy of the initial equation I came up with? Because I have doubt about it. I think the first term should be $\frac{1}{2}(e+1) + \frac{1}{2}(e+1)$.
Why twice? Because this can occur if we get first toss as Tail (T) as well as if we get first two consecutive tosses as Heads (H) meaning the first Head (H) is useless and hence would act only to increase the expected number of toss by 1. Is that the case?
The reasoning from the TTT problem doesn't directly translate to the HTTT problem. In the TTT problem, if you get a few T's (fewer than k) and then an H, you're back to where you started: looking for the first occurrence of TTTT. In the HTTT problem, if you get an HT[...]TH with fewer than k T's, it sets you back but not all the way back: you're looking for TTT, not for HTTT (because you've already got an H). You're going to need more than one variable.
A simple solution is to notice that the process consists of two parts:
The expected total number of tosses is just the sum of the two, i.e. $2 + (2^{k+1}-2) = 2^{k+1}$
Closer to your line of reasoning: let $e_1$ be the answer to the problem (expected number of tosses until HTTT...T), $e_2$ be the expected number of remaining tosses given that the previous outcome is H. Consider $e_1$. If the first outcome is H, the answer is $e_2+1$. If the first outcome is T, we're back to where we started, so the answer is $e_1+1$. So:
$$ e_1=\frac{1}{2}(e_2+1)+\frac{1}{2}(e_1+1)\\ e_1=e_2+2 $$
Similarly, for $e_2$ we consider the mutually exclusive prefixes H (with answer $e_2+1$), TH ($e_2$+2), TTH ($e_2+3$), ..., TT...TH (k-1 T's) ($e_2+k$) and finally TTT...T (k T's) ($k$, since that's the end of the sequence), so we get the equation $$ e_2=\left(\frac{1}{2}(e_2+1)+\frac{1}{4}(e_2+2)+...+\frac{1}{2^k}(e_2+k)\right)+\frac{1}{2^k}k\\ e_2=2^{k+1}-2 $$
Note that this problem is a bit of a special case: the equation for $e_2$ doesn't involve $e_1$, so we could solve the equations for $e_1$ and $e_2$ independently. For an arbitrary string we'd get a system of linear equations. Exercise: HTH. Answer: (spoiler!)