I am currently working on the state transition of a system execution cycle and applying some mathematical computations over it to get various other values.
Please refer the diagram below to understand the state flow diagram of the system.

The probability matrix of the following transition is as follows,
$$ \begin{bmatrix} 0& .5& 0& 0& 0& 0& 0& 0& 0& .5\\ 0& 0& .33& .33& .33& 0& 0& 0& 0& 0\\ 0& 0& 0& 0& 0& .5& .5& 0& 0& 0\\ .5& 0& .5& 0& 0& 0& 0& 0& 0& 0\\ 1& 0& 0& 0& 0& 0& 0& 0& 0& 0\\ 0& 0& 0& 0& 0& 0& 0& .5& .5& 0\\ 1& 0& 0& 0& 0& 0& 0& 0& 0& 0\\ 0& 0& 0& 0& 0& 0& 0& 1& 0& 0\\ 0& 0& 0& 0& 0& 0& 0& .5& 0& .5\\ 0& 0& 0& 0& 0& 0& 0& 0& 0& 1 \end{bmatrix}$$
Now my need is that I want to calculate the probability of state transition from $S20 \to S40$. I am using Bayes formula for calculating it.
$$\operatorname{Pr}(S40|S20) = \frac{\operatorname{Pr}(S20|S40) \operatorname{Pr}(S40)}{P(S20)}$$
Now I need assistance in,
- Confirming that I am using the right approach.
- How will I evaluate $\operatorname{Pr}(S20|S40)$? For all the other values can be referred from the matrix.
I assume your matrix orders the events in the following way: $$\{S10,S15,S20,S21,S22,S30,S31,S40,S41,S41\}.$$
Then, the fact that $$\operatorname{Pr}(S20)=\operatorname{Pr}(S15\to S20)=0.33,$$ can be simply read off the transition matrix. Since $S40$ only happens if $S20$ happened first, it follows that $$\operatorname{Pr}(S20|S40)=1.$$
Finally, $$\operatorname{Pr}(S40)=\operatorname{Pr}(S15\to S20)\operatorname{Pr}(S20\to S30)\operatorname{Pr}(S30\to S40)=0.33*0.5*0.5=0.0825,$$ and $$\operatorname{Pr}(S40|S20)=\frac{0.0825}{0.33}=0.25.$$