# How to generate a realization from a transition matrix?

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 ]])
$$$$
`
• 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. – whuber Jan 12 at 20:42
• 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. – Xi'an Jan 13 at 8:02