0
$\begingroup$

Consider a Markov chain of 4 states described by the transition matrix, $$ T_{ij} = \begin{bmatrix} 0.40 & 0.56 & 0.03 & 0.01\\ 0.45 & 0.51 & 0.04 & 0.00\\ 0.25 & 0.25 & 0.25 & 0.25 \\ 0.00 & 0.00 & 0.01 & 0.99 \end{bmatrix} $$

How can I generate a realisation of the Markov chain from it in python using the numpy arrays? What exactly it means by realisation of the Markov chain?

import numpy as np

x = np.array([ [ 0.40, 0.56, 0.03, 0.01],
               [0.45, 0.51, 0.04, 0.00],
               [0.25, 0.25, 0.25, 0.25 ],
               [0.00, 0.00, 0.01, 0.99 ]])
```
$\endgroup$
2
  • $\begingroup$ See stats.stackexchange.com/search?q=simulate+markov+chain. Using that search I found my old post at stats.stackexchange.com/a/115956/919 which contains complete code to simulate a Markov chain from a transition matrix. $\endgroup$ – whuber Jan 12 at 20:42
  • 1
    $\begingroup$ A realisation of a Markov chain requires (a) a starting distribution and (b) a number of terms in the sequence. Given these inputs, the Markov property means generating one term after and conditional on another. $\endgroup$ – Xi'an Jan 13 at 8:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.