Markov jump-process generator (source code)

= Markov jump-process generator

For transition rates $q_{nm}$, the generator acts on a function $f$ by
$$
(Lf)(n)=\sum_{m\ne n}q_{nm}\bigl(f(m)-f(n)\bigr).
$$
Whenever the expectations are finite,
$$
\frac d{dt}\mathbb E[f(N_t)]=\mathbb E[(Lf)(N_t)].
$$
Choosing polynomial functions $f$ gives differential equations for the moments.