Expected finite-horizon occupation time (source code)

= Expected finite-horizon occupation time
{title2=$\mathbb E_iO_j(T)=\int_0^T(e^{tQ})_{ij}\,dt$}

For a finite-state homogeneous <continuous-time Markov chain> with <generator matrix> $Q$, integrate the indicator of occupying state $j$ over $[0,T]$. Interchanging the bounded time integral and <expected value> gives the displayed integral of <transition probabilities>. It counts all visits, not only the first <holding time>. Summing over states gives $T$. A zero <eigenvalue> of $Q$ does not cause a problem for this integral, although it prevents casually writing it with an <inverse matrix> $Q^{-1}$.