Simulation of a continous Markov chain in Matlab?

1.1k Views Asked by At

Can anyone help me with the code to simulate a continuous time Markov chain? I could not figure out how to write code for a continuous time Markov chain. I would appreciate any help. Thank you in advance.

1

There are 1 best solutions below

2
On

The standard way to simulate a time-homogeneous CTMC is to convert it to the associated "jump chain", which is a DTMC, with associated holding times. To do this, you consider a DTMC with jump probabilities $p_{ij}=-q_{ij}/q_{ii}$, where $Q$ is the generator matrix, and $p_{ii}=0$. Then you sample the holding time at $i$ as an exponential random variable with rate $-q_{ii}$.

As for simulating the DTMC, that is basically just a matter of sampling from a discrete distribution many times.

In the time-inhomogeneous case, in general you have to take a step size $h$ (which might itself depend on time) and say that you stay at $i$ with probability $1+hq_{ii}$ and go to $j$ with probability $hq_{ij}$. In the time-homogeneous case, this approach wastes samples (because when $h$ is small, most time steps are not jumps) and unnecessarily discretizes the holding time distribution.