Coin flipping probability problem. You flip a fair coin until you see three tails in a row. What is the average number of heads
that you’ll see until getting T T T? (3 tails in a row).
My math got me to about 21 heads before it happens, and I wanted to know if that is correct. Thanks!
 A: So, we can approach this via markov chains and their corresponding stochastic and fundamental matrices.
The stochastic matrix with corresponding states from left to right as 3tails, 2tails, 1tail, 0tails is:
$$\begin{bmatrix}1&\frac{1}{2}&0&0\\0&0&\frac{1}{2}&0\\0&0&0&\frac{1}{2}\\0&\frac{1}{2}&\frac{1}{2}&\frac{1}{2}\end{bmatrix}$$
We turn our attention now to the fundamental matrix:
$(I-R)^{-1}=\left(\begin{bmatrix}1&0&0\\0&1&0\\0&0&1\end{bmatrix}-\begin{bmatrix}0&\frac{1}{2}&0\\0&0&\frac{1}{2}\\\frac{1}{2}&\frac{1}{2}&\frac{1}{2}\end{bmatrix}\right)^{-1}$
$=\begin{bmatrix}1&-\frac{1}{2}&0\\0&1&-\frac{1}{2}\\-\frac{1}{2}&-\frac{1}{2}&\frac{1}{2}\end{bmatrix} = \begin{bmatrix}2&2&2\\2&4&4\\4&6&8\end{bmatrix}$
We start in the state 0tails at the beginning of the game, so we focus our attention to the third column of the fundamental matrix.  By looking at the fundamental matrix, we can gain quite a bit of information.  In particular, the sum of the column corresponds to the number of flips on average until we reach an absorbing state (in this case 3 tails in a row).  There will be $2+4+8=14$ flips on average until you reach three tails in a row.
By looking at the entries of the matrix individually, you can tell how many times you are expected to be in each specific state.  In our specific case, we look to the bottom right entry which is an $8$ and this corresponds to the number of times we move to the state 0tails, which corresponds to one time at the very start and otherwise is equivalent to having flipped a head.
Thus there are a total expected number of $7$ heads.

tldr: $7$ heads are expected to have been seen by the time you have flipped three tails in a row.
A: The correct answer is that the expected number of heads (or tails) is $7$.
Not 8.
The expected length of sequence is indeed 14, as shown by @JMoravitz.  But at each epoch, ther is some probability distribution for each of the four possible states of last-two flips.  And given this distribution, the expected increase in number of heads rolled is exactly equal to the expected increase in the number of tails rolled.  So the answer is $14/2$. 
