User:Aiden Fisher/Sandbox

Expected finishing time
The initial state of the system at time zero is state 2, which we represent by the probability vector v:


 * $$ \mathbf{v} =

\begin{bmatrix} 0 & 1 & 0 & 0 & 0 \end{bmatrix}.$$

The probability distribution of the states at time k is then given by


 * $$ \mathbf{p}_k = \mathbf{v}P^k \, ,$$

or alternativly,


 * $$ \mathbf{p}_k = \mathbf{p}_{k-1}P \, .$$

The game ends when we reach state 5. So if we define $$\mathbf{e}_5$$ as a column vector of zeros with 1 in the fifth entry the probability that the game has ended at time $$k$$ is,


 * $$p_{k}=\mathbf{v}P^k\mathbf{e}_{5}\,.$$

The expected time until the game has ended is K,


 * $$E[K]=\sum_{k=0}^{\infty}k(1-p_{k})=\sum_{k=0}^{\infty}k(1-\mathbf{v}P^k\mathbf{e}_{5})=4.5$$