Probability of flipping coin What is the probability of obtaining THT before HHH when a toss is tossed sequentially? Could someone solve using state diagram and law of total probability?
 A: We have some sub-states to reach before obtaining THT or HHH:
$\begin{matrix}T\\H\\TH\\HH\\THT\\HHH\end{matrix}$
where state H means the previous toss is H but the previous two tosses does not generate both TH and HH (so H must be the first toss), and so on.
Now we could have the state transform matrix for each toss
$M=\begin{pmatrix}1/2&0&1/2&0&0&0\\1/2&0&0&1/2&0&0\\0&0&0&1/2&1/2&0\\1/2&0&0&0&0&1/2\\0&0&0&0&1&0\\0&0&0&0&0&1\end{pmatrix}$
The last rows of M means as soon as state THT or HHH is reached the final state is determined.
The first toss has 1/2 probability to reach state T and another 1/2 probability to reach state H so that the initial probability distribution is 
$v=\begin{pmatrix}1/2&1/2&0&0&0&0\end{pmatrix}$
So after tossing n times, the distribution of final states is $v*M^n$ and what we need is $\lim_{n\to\infty} v*M^n=\begin{pmatrix}0&0&0&0&7/12&5/12\end{pmatrix}$
which means the probability to reach THT before HHH is 7/12.
The result could be calculated by analysis the characteristic polynomial of matrix M.
