qspec logo qspec logo

A physics toolbox for laser spectroscopy.

Static Badge Static Badge Static Badge

Static Badge Static Badge

© 2026 Patrick Müller. All rights reserved.

qspec.simulate. ct_markov_dgl  (  t ,  n ,  rates ,  r=1.0 ,  p0=None ,  time_resolved=False ,  show=False  )[source]

The numerical solution of the evolution of a linear continuous-time Markov chain, see ct_markov_analytic, obtained by solving the underlying system of ordinary differential equations

$$ \frac{\mathrm{d}P_0}{\mathrm{d}t} = -\lambda_0P_0,\quad \frac{\mathrm{d}P_i}{\mathrm{d}t} = r\lambda_{i - 1}P_{i - 1} - \lambda_iP_i. $$
Parameters:
tarray_like

The time $t$ after which the probabilities are returned (μs). If all times from 0 to t are required, use time_resolved=True.

nint_like

The maximum state number $n$ to compute. The first state corresponds to n = 0.

ratesarray_like

The rate(s) $\lambda_i$ at which the Markov chain transfers population from the state $i$ to the state $i + 1$ (MHz). If rates is a scalar, this rate is assumed for all $0 \leq i \leq n$. If rates is an iterable, it must have size n + 1 and individual rates rates[i] are assumed for the states $i$.

rarray_like

The ratio $r$ of the population which is transferred from the state $i$ to the state $i + 1$. Then $1 - r$ is the ratio of the population that is lost during the transition.

p0array_like | None

The initial probabilities $P_i(0)$. Must be an iterable of size n + 1. If None, p0 is set to [1, 0, 0, ..., 0].

time_resolvedbool

Whether to return the complete history of the result. If True, a 2-tuple (t, p) is returned, where p has shape (t.size, n + 1) and t is an array of equally spaced times, such that numerical integrations can be performed easily.

showbool

Whether to plot the result.

Returns:
pndarray | tuple[ndarray, ndarray]

The probabilities $P_i(t)$ of the states $0 \leq i \leq n$ after the time t.

Raises:
ValueError

If t is not a scalar, if rates or p0 have the wrong size, or if r is not a scalar between 0 and 1.