<li>Pick an initial state <span class="math inline">\(X_t=i\)</span>.</li>
<li>For t = 1…T:
<ol style="list-style-type: decimal">
<li>Obtain the row of <span class="math inline">\(P\)</span> corresponding to the current state <span class="math inline">\(X_t\)</span>.</li>
<li>Generate <span class="math inline">\(X_{t+1}\)</span> from a multinomial distribution with probability vector equal to the row we obtained above.</li>
</ol></li>
</ol>
<p>We implement this in the following function, initializing the 