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_analytic  (  t ,  n ,  rates ,  r=1.0  )[source]

The analytic solution of the evolution of a linear continuous-time Markov chain $0\rightarrow 1\rightarrow 2\rightarrow\dots$ with the rates $\lambda_i$, starting in the state 0. For a constant rate $\lambda$, this is the Poisson distribution

$$ P(n, t) = \frac{(r\lambda t)^n}{n!}e^{-\lambda t}. $$

For individual rates, the analytic solution can be numerically unstable, since very small numbers are multiplied with very large numbers. See ct_markov_dgl for a numerical solution.

Parameters:
tarray_like

The time $t$ at which the probability is returned (μs).

narray_like

The number $n$ of the state for which the probability is returned. 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 length max(n) + 1 and individual rates rates[i] are assumed for the states $0 \leq i \leq n$.

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.

Returns:
pndarray

The probability $P(n, t)$ for the Markov chain to be in the state n after the time t, with $P(0, 0) = 1$. If t and n are iterables, a 2d-array with shape (t.size, n.size) is returned.

Raises:
ValueError

If r is not a scalar between 0 and 1.