title: Probability of two transitions in Markov Chain
body: <p>I've gotten a grasp on the transition matrices of Markov models, but am still a bit unclear on how to make a series of transitions. Consider the Markov chain at the bottom of the page where <code>S</code> = Sunny, <code>C</code> = Cloudy, <code>R</code> = Rainy.</p>
  
  <p>I have set up this transition matrix in MATLAB</p>
  
  <pre><code>A = [0.1 0.2 0.7; 0.4 0.3 0.3; 0.2 0.6 0.2]
  
      0.1000    0.2000    0.7000
      0.4000    0.3000    0.3000
      0.2000    0.6000    0.2000
  </code></pre>
  
  <p>Now to look up the probability of a transition, I made the following variables for convenience</p>
  
  <pre><code>&gt;&gt; S = 1
  &gt;&gt; R = 2
  &gt;&gt; C = 3
  </code></pre>
  
  <p>You can find the probability of a single transition just by looking it up from the table, for example from Rainy today to Sunny tomorrow would be</p>
  
  <pre><code>&gt;&gt; A(R,S)
  ans = 0.4000
  </code></pre>
  
  <p><strong>Question</strong></p>
  
  <p>I'm having a hard time understanding how to do a series of transitions. For example, if today is Sunny, what is the chance that two days from now it will be Cloudy? (so basically two transitions) I was thinking</p>
  
  <pre><code>&gt;&gt; A(S,S)*A(S,C) + A(S,R)*A(R,C) + A(S,C)*A(C,C)
  ans = 0.2700
  </code></pre>
  
  <p>Basically I found all possible transitions that could end up at Cloudy from Sunny. Although cumbersome, is that the correct way to go about it?</p>
  
  <p><img src="https://i.stack.imgur.com/8273m.png" alt="enter image description here"></p>