r(c in seq_len(num.chains)){
  chain.states[,c] &lt;- run.mc.sim(P)
}</code></pre>
<p>Our function returns a vector that contains the states of our simulated chain through time. Recall that our state space is <span class="math inline">\(\{1,2,3\}\)</span>. Below, we visualize how these chains evolve through time:</p>
<pre class="r"><code>matplot(chain.states, type=&#39;l&#39;, lty=1, col=1:5, ylim=c(0,4), ylab=&#39;state&#39;, xlab=&#39;time&#39;)
abline(h=1, lty=3)
abline(h=3, lty=3)</code></pre>
<p><img s