Tutorials › Stochastic Processes › Expected State Occupancy Over a Fixed Time Horizon

Kolmogorov Equations and Transient Behavior · Tutorial 503 of 994

Expected State Occupancy Over a Fixed Time Horizon

Translate transition probabilities over time into expected time spent in each state, and check the resulting occupancy calculations.

Advanced 12 min read

What You'll Learn

  • Define the occupation time of a state over a fixed horizon.
  • Derive expected occupancy by integrating transition probabilities.
  • Use the matrix integral identity without incorrectly inverting a generator.
  • Compute exact occupancy times for two-state and absorbing three-state chains.
  • Check occupancy totals and diagnose an endpoint-probability approximation.

From Transition Probabilities to Occupancy Time

A transition probability describes the state of a process at one instant. Many questions instead concern the whole interval: how long, on average, will a system spend in a particular state before a fixed deadline? Examples include expected time in a disease stage during follow-up, time a machine spends operational, or time a queue spends empty. For a finite-state continuous-time Markov chain, the answer comes from integrating the transition probabilities over the observation window.

Let \((X_t)_{t\ge0}\) be a continuous-time Markov chain on a finite state space \(S\), defined on a probability space \((\Omega,\mathcal{F},\mathbb{P})\). Write \(P(t)=(p_{ij}(t))\), where \(p_{ij}(t)=\mathbb{P}_i(X_t=j)\), and let \(Q=(q_{ij})\) be its generator, so \(P(t)=e^{tQ}\). For a fixed horizon \(T\ge0\), define the occupation time of state \(j\) by \[ C_j(T)=\int_0^T \mathbf{1}_{\{X_t=j\}}\,dt. \] This random variable measures the total amount of time spent in \(j\), not merely whether the chain is in \(j\) at time \(T\).

Theorem (Expected occupancy): For any finite-state continuous-time Markov chain, any initial state \(i\), state \(j\), and finite \(T\ge0\), \[ \mathbb{E}_i[C_j(T)]=\int_0^T p_{ij}(t)\,dt. \] If the initial distribution is the row vector \(\mu\), then the row vector of expected occupation times is \(\mu A(T)\), where \(A(T)=\int_0^T P(t)\,dt\).

Proof. The integrand \(\mathbf{1}_{\{X_t=j\}}\) is nonnegative and measurable. Tonelli's theorem therefore allows expectation and time integration to be interchanged: \[ \mathbb{E}_i[C_j(T)] =\mathbb{E}_i\left[\int_0^T\mathbf{1}_{\{X_t=j\}}\,dt\right] =\int_0^T\mathbb{E}_i[\mathbf{1}_{\{X_t=j\}}]\,dt =\int_0^T\mathbb{P}_i(X_t=j)\,dt. \] For initial distribution \(\mu\), the probability of being in state \(j\) at time \(t\) is the \(j\)th entry of \(\mu P(t)\). Integrating this finite row vector entry by entry gives \(\mu\int_0^T P(t)\,dt=\mu A(T)\). \(\square\)

Because the state indicators sum to one at every time, total occupation has a useful check: \(\sum_{j\in S}C_j(T)=T\) on every path. Consequently, the expected occupation times must sum to \(T\) as well. This check applies for every initial state and every initial distribution.

The Matrix Integral and Its Limitation

The occupancy matrix \(A(T)\) collects all the integrals \(\int_0^T p_{ij}(t)\,dt\). It has a direct identity in terms of the generator and the transition matrix at the horizon. This identity is useful computationally, but a tempting inverse formula is generally unavailable: every finite-state generator has row sums zero, so it is singular.

Theorem (Integrated semigroup identity): For a finite-state generator \(Q\) and \(T\ge0\), \[ Q A(T)=A(T)Q=P(T)-I. \] In particular, \(A(T)\) is not obtained by writing \(Q^{-1}(P(T)-I)\), because \(Q^{-1}\) does not exist for a finite-state generator.

Proof. The matrix exponential satisfies \(\frac{d}{dt}P(t)=QP(t)=P(t)Q\), and \(P(0)=I\). Integrating the first equality entry by entry gives \[ Q A(T)=Q\int_0^T P(t)\,dt =\int_0^T QP(t)\,dt =P(T)-P(0)=P(T)-I. \] Integrating the second equality gives \(A(T)Q=P(T)-I\). To see why \(Q\) is singular, let \(\mathbf{1}\) be the column vector of ones. Its \(i\)th entry after multiplication by \(Q\) is \(\sum_jq_{ij}=0\), so \(Q\mathbf{1}=0\). Since \(\mathbf{1}\ne0\), \(Q\) has a nonzero vector in its null space and has no inverse. \(\square\)

The identity is not, by itself, a prescription to divide by \(Q\). One can integrate explicit entries of \(P(t)\), as in the examples below, or use a suitable matrix-exponential computation. In either case the occupancy theorem explains why the integral is the quantity required. The identity also provides a check on a computed integral: multiplying it by \(Q\) should give \(P(T)-I\).

Worked Example: A Two-State Switching Chain

Let \(S=\{0,1\}\), and consider a chain on a probability space \((\Omega,\mathcal{F},\mathbb{P})\) that switches from \(0\) to \(1\) at rate \(1\) and from \(1\) to \(0\) at rate \(2\). Its generator is \[ Q=\begin{bmatrix}-1&1\\2&-2\end{bmatrix}. \] The first row sums to \(-1+1=0\), and the second to \(2-2=0\), as required. Start at state \(0\), and find the expected time in state \(1\) by \(T=\ln 2\).

The transition probabilities are \[ p_{01}(t)=\frac{1}{3}(1-e^{-3t}),\qquad p_{00}(t)=\frac{2}{3}+\frac{1}{3}e^{-3t}, \] and \[ p_{10}(t)=\frac{2}{3}(1-e^{-3t}),\qquad p_{11}(t)=\frac{1}{3}+\frac{2}{3}e^{-3t}. \] Each row sums to one: \(p_{00}(t)+p_{01}(t)=\frac23+\frac13e^{-3t}+\frac13-\frac13e^{-3t}=1\), and \(p_{10}(t)+p_{11}(t)=\frac23-\frac23e^{-3t}+\frac13+\frac23e^{-3t}=1\).

By the occupancy theorem, the expected time in state \(1\) is \[ \begin{aligned} \mathbb{E}_0[C_1(\ln 2)] &=\int_0^{\ln 2}\frac13(1-e^{-3t})\,dt\\ &=\frac{\ln 2}{3}-\frac{1-e^{-3\ln 2}}{9}\\ &=\frac{\ln 2}{3}-\frac{7}{72}, \end{aligned} \] because \(e^{-3\ln 2}=2^{-3}=\frac18\), so \((1-\frac18)/9=7/72\). The expected time in state \(0\) is the horizon minus this amount: \[ \mathbb{E}_0[C_0(\ln 2)]=\ln 2-\left(\frac{\ln 2}{3}-\frac{7}{72}\right) =\frac{2\ln 2}{3}+\frac{7}{72}. \]

Check: the two expected occupation times sum to \(\frac{\ln 2}{3}-\frac{7}{72}+\frac{2\ln 2}{3}+\frac{7}{72}=\ln 2\), the full horizon. The calculation integrates probabilities over all times; it does not use only the endpoint probability \(p_{01}(\ln 2)=\frac13(1-\frac18)=\frac7{24}\).

Initial Distributions and State Occupancy

When the starting state is random, occupancy is an average over the possible starting states. The row-vector convention makes this immediate: at time \(t\), the distribution is \(\mu P(t)\), and integrating gives \(\mu A(T)\). The next calculation shows how the initial distribution changes the occupancy even though the generator and horizon remain fixed.

Worked Example: A Mixed Starting State

Use the same two-state chain, now with initial distribution \(\mu=(\frac12,\frac12)\) and horizon \(T=\ln 2\). The generator rows still sum to zero, and the transition matrix rows still sum to one as checked above. The probability of state \(1\) at time \(t\) is the second entry of \(\mu P(t)\): \[ \begin{aligned} \mathbb{P}(X_t=1) &=\frac12p_{01}(t)+\frac12p_{11}(t)\\ &=\frac12\cdot\frac13(1-e^{-3t}) +\frac12\left(\frac13+\frac23e^{-3t}\right)\\ &=\frac13+\frac16e^{-3t}. \end{aligned} \]

Therefore, \[ \begin{aligned} \mathbb{E}[C_1(\ln 2)] &=\int_0^{\ln 2}\left(\frac13+\frac16e^{-3t}\right)\,dt\\ &=\frac{\ln 2}{3}+\frac{1-e^{-3\ln 2}}{18}\\ &=\frac{\ln 2}{3}+\frac{7}{144}. \end{aligned} \] The expected time in state \(0\) is \[ \mathbb{E}[C_0(\ln 2)] =\ln 2-\left(\frac{\ln 2}{3}+\frac{7}{144}\right) =\frac{2\ln 2}{3}-\frac{7}{144}. \]

Check by conditioning on the initial state: from state \(0\), the state-\(1\) occupancy is \(\frac{\ln 2}{3}-\frac{7}{72}\). From state \(1\), integrating \(p_{11}(t)\) gives \(\frac{\ln 2}{3}+\frac{2}{9}(1-\frac18)=\frac{\ln 2}{3}+\frac{7}{36}\). Their average is \[ \frac12\left(\frac{\ln 2}{3}-\frac{7}{72}\right) +\frac12\left(\frac{\ln 2}{3}+\frac{7}{36}\right) =\frac{\ln 2}{3}+\frac{7}{144}, \] as obtained from \(\mu P(t)\). The two state occupancies also sum to \(\ln 2\).

An Absorbing Three-State Example

In an absorbing chain, occupancy of a transient state records time spent there before leaving, while occupancy of an absorbing state accumulates after absorption. The integral formula handles both in the same way. In particular, the probability of being in an absorbing state at time \(t\) is not itself an expected time; it must also be integrated across the horizon.

Worked Example: Sequential Absorption

Let \(S=\{0,1,2\}\) and let the chain move from \(0\) to \(1\) at rate \(1\), from \(1\) to absorbing state \(2\) at rate \(1\), and remain at \(2\). On a probability space \((\Omega,\mathcal{F},\mathbb{P})\), start the chain at \(0\) and take \(T=1\). The generator is \[ Q=\begin{bmatrix}-1&1&0\\0&-1&1\\0&0&0\end{bmatrix}. \] Its rows sum to \(-1+1+0=0\), \(0-1+1=0\), and \(0+0+0=0\).

The transition probabilities are \[ P(t)= \begin{bmatrix} e^{-t}&te^{-t}&1-(1+t)e^{-t}\\ 0&e^{-t}&1-e^{-t}\\ 0&0&1 \end{bmatrix}. \] For example, starting from \(0\), the probability of still being in \(0\) is \(e^{-t}\). The forward equation for the probability of state \(1\) is \(p'_{01}(t)=p_{00}(t)-p_{01}(t)\), with \(p_{01}(0)=0\); substituting \(p_{00}(t)=e^{-t}\) gives \(p_{01}(t)=te^{-t}\). The remaining probability is in state \(2\). Each row sums to one: the first is \(e^{-t}+te^{-t}+1-(1+t)e^{-t}=1\); the second is \(e^{-t}+1-e^{-t}=1\); and the third is \(1\).

Integrating the first row over \([0,1]\) gives each expected occupancy from the specified initial state: \[ \mathbb{E}_0[C_0(1)]=\int_0^1e^{-t}\,dt=1-e^{-1}, \] \[ \mathbb{E}_0[C_1(1)]=\int_0^1te^{-t}\,dt =\left[-(t+1)e^{-t}\right]_0^1 =1-2e^{-1}, \] and \[ \begin{aligned} \mathbb{E}_0[C_2(1)] &=\int_0^1\left(1-(1+t)e^{-t}\right)\,dt\\ &=1-\left((1-e^{-1})+(1-2e^{-1})\right)\\ &=3e^{-1}-1. \end{aligned} \]

Check: adding the three values gives \((1-e^{-1})+(1-2e^{-1})+(3e^{-1}-1)=1\), the full horizon. Each value also comes from integrating the corresponding entry of the first transition-matrix row, not from treating the terminal probabilities as time totals.

Interpretation and a Common Error

Expected occupancy has a direct reward interpretation. If state \(j\) earns reward at constant rate \(r_j\), then the total reward by time \(T\) is \(\int_0^T r_{X_t}\,dt\). Since the state space is finite, this is \(\sum_j r_jC_j(T)\), so its expectation is \(\sum_j r_j\mathbb{E}[C_j(T)]\). Thus an occupancy calculation can answer questions about expected cost, exposure, workload, or time in a clinical state by assigning a rate to each state.

Common mistake: multiplying the endpoint probability by the horizon. In the first two-state example, this would give \((\ln 2)p_{01}(\ln 2)=(\ln 2)\frac7{24}\) as the expected time in state \(1\). That is not the occupancy integral: it assumes the probability of state \(1\) was constant at its value at the endpoint throughout the interval. The correct value is \(\frac{\ln 2}{3}-\frac7{72}\), obtained from \(\int_0^{\ln 2}\frac13(1-e^{-3t})\,dt\). The endpoint probability is a snapshot, whereas occupancy accumulates contributions from every time in the interval.

For any finite horizon, useful checks are to confirm that generator rows sum to zero, transition-probability rows sum to one, and expected occupancies sum to \(T\). The integrated semigroup identity supplies an additional matrix check. These checks do not replace the integral, but they often expose an incorrect transition entry, a sign error, or an omitted state.

Check Your Understanding

Use the occupancy integral and verify your results by checking the total expected time.

  1. For a two-state chain with rates \(1\) from \(0\) to \(1\) and \(2\) from \(1\) to \(0\), write the integral for expected time in state \(1\) by horizon \(T\), starting from \(0\).
  2. Explain why the expected occupation times over all states must sum to \(T\), for a fixed finite horizon.
  3. For the sequential absorbing chain, identify which transition probability must be integrated to find expected time in the absorbing state by time \(1\).
  4. Why can the integrated semigroup identity not generally be rearranged using \(Q^{-1}\)?
  5. Describe the error in approximating expected occupancy by \(T\) times the probability of being in the state at time \(T\).