Alessandro Palliccia

Stochastic Dynamical Models

Invariant densities of Markov chains

1,241 words,

Which distributions of the initial state of a Markov chain are passed on unchanged to the state at every later time? Whether a chain has such a distribution, and how many, depends on its transition matrix.

Invariant densities

Let (Xn)n≥0(X_n)_{n \ge 0} be a Markov chain on the probability space (Ω,F,P)(\Omega, \mathcal{F}, \mathbb{P}) with set of states II and transition matrix P=(pij)i,j∈I.{P = (p_{ij})_{i, j \in I}.} As in the previous posts, Pi\mathbb{P}_i is the conditional probability given X0=i,{X_0 = i,} and pij(n)=Pi{Xn=j}{p^{(n)}_{ij} = \mathbb{P}_i\{X_n = j\}} is the entry (i,j)(i, j) of the power Pn.{P^n.}

Definition 5.1 (Invariant probability measure). A probability measure μ\mu on II is called invariant for the Markov chain (Xn)n≥0(X_n)_{n \ge 0} if, when X0X_0 has distribution μ,{\mu,} the random variable XnX_n has distribution μ\mu for all n≥0.{n \ge 0.}

In Definition 5.1 and below, we identify a probability measure on II with its density with respect to the counting measure on the σ\sigma-algebra of all subsets of I.{I.} This density is the collection of numbers (μi)i∈I(\mu_i)_{i \in I} in the interval [0,1][0, 1] such that ∑i∈Iμi=1.{\sum_{i \in I} \mu_i = 1.} The number μi\mu_i is the measure of the set {i},{\{i\},} and the measure of a set of states is the sum of the numbers μi\mu_i of its elements.

Proposition 5.2. A probability measure μ\mu on II is invariant for the Markov chain (Xn)n≥0(X_n)_{n \ge 0} if and only if, for every state i,{i,} we have

μi=∑j∈Iμjpji,(9)\mu_i = \sum_{j \in I} \mu_j p_{ji}, \tag{9}

that is, the density of μ\mu is a left eigenvector of the transition matrix with eigenvalue 1.

Proof (complete). Let μ\mu be the probability distribution of X0.{X_0.} The probability distribution ν\nu of X1X_1 has density

νi=P{X1=i}=∑j∈IP{X0=j}pji=∑j∈Iμjpji.\nu_i = \mathbb{P}\{X_1 = i\} = \sum_{j \in I} \mathbb{P}\{X_0 = j\} p_{ji} = \sum_{j \in I} \mu_j p_{ji}.

Indeed, the events {X0=j}{\{X_0 = j\}} with j∈I{j \in I} are disjoint and their union is Ω,{\Omega,} and P{X0=j,X1=i}=P{X0=j}pji{\mathbb{P}\{X_0 = j, X_1 = i\} = \mathbb{P}\{X_0 = j\} p_{ji}} by (1.1) of the first post. Therefore, if μ\mu is an invariant probability measure for the Markov chain (Xn)n≥0,{(X_n)_{n \ge 0},} then ν=μ{\nu = \mu} and (9) holds.

Conversely, if μ\mu is a probability measure on II satisfying (9),{(9),} then XnX_n has probability distribution μ\mu for all n.{n.} To see this, argue by induction on n,{n,} the case n=0{n = 0} being the choice of X0.{X_0.} If XnX_n has distribution μ,{\mu,} then P{Xn=j,Xn+1=i}=P{Xn=j}pji{\mathbb{P}\{X_n = j, X_{n+1} = i\} = \mathbb{P}\{X_n = j\} p_{ji}} by (1.1) of the first post summed over the states at the times 0,…,n−1,{0, \dots, n - 1,} so the computation above, repeated at the times nn and n+1,{n + 1,} gives P{Xn+1=i}=∑jμjpji=μi{\mathbb{P}\{X_{n+1} = i\} = \sum_{j} \mu_j p_{ji} = \mu_i} by (9). ■\blacksquare

Summing up, a probability measure μ\mu on I,{I,} with its density identified with the row vector (μi)i∈I,{(\mu_i)_{i \in I},} is invariant if and only if

μ=μP.\mu = \mu P.

Theorem 5.3. If the set of states II is finite, then there exists at least one invariant probability measure.

Proof (complete). The set of probability densities on II

K={(μi)i∈I:0≤μi≤1 for every i, ∑i∈Iμi=1}\mathcal{K} = \Big\{ (\mu_i)_{i \in I} : 0 \le \mu_i \le 1 \text{ for every } i, \ \sum_{i \in I} \mu_i = 1 \Big\}

is compact, as a closed bounded subset of Rcard(I).{\mathbb{R}^{\mathrm{card}(I)}.} Let μ(0)∈K.{\mu^{(0)} \in \mathcal{K}.} For all n≥1,{n \ge 1,} the family of real numbers (μj(n))j∈I(\mu^{(n)}_j)_{j \in I} defined by

μj(n)=1n∑k=1n(∑i∈Iμi(0)pij(k))\mu^{(n)}_j = \frac1n \sum_{k=1}^{n} \Big( \sum_{i \in I} \mu^{(0)}_i p^{(k)}_{ij} \Big)

is a probability density on I.{I.} Since the set K\mathcal{K} is compact, by considering a subsequence, if necessary, we can assume that the sequence (μj(n))n≥1(\mu^{(n)}_j)_{n \ge 1} is convergent for all j∈I.{j \in I.} Defining πj=lim⁡n→∞μj(n),{\pi_j = \lim_{n \to \infty} \mu^{(n)}_j,} the collection of real numbers (πj)j∈I(\pi_j)_{j \in I} is a probability density on II and, moreover,

∑i∈Iπipij=lim⁡n→∞1n∑k=1n(∑i∈Iμi(0)pij(k+1))=lim⁡n→∞1n+1∑k=1n+1(∑i∈Iμi(0)pij(k))−lim⁡n→∞1n+1∑i∈Iμi(0)pij=πj\begin{aligned} \sum_{i \in I} \pi_i p_{ij} &= \lim_{n \to \infty} \frac1n \sum_{k=1}^{n} \Big( \sum_{i \in I} \mu^{(0)}_i p^{(k+1)}_{ij} \Big) \\ &= \lim_{n \to \infty} \frac{1}{n+1} \sum_{k=1}^{n+1} \Big( \sum_{i \in I} \mu^{(0)}_i p^{(k)}_{ij} \Big) - \lim_{n \to \infty} \frac{1}{n+1} \sum_{i \in I} \mu^{(0)}_i p_{ij} \\ &= \pi_j \end{aligned}

for all j∈I.{j \in I.} This proves that the probability measure with density (πi)i∈I(\pi_i)_{i \in I} is invariant for the Markov chain. ■\blacksquare

In the proof above, the invariant probability density is obtained as a limit of subsequences of (μ(n))n≥1,{(\mu^{(n)})_{n \ge 1},} where μ(0)\mu^{(0)} is a density on II and

μj(n)=1n∑k=1n(μ(0)Pk)j\mu^{(n)}_j = \frac1n \sum_{k=1}^{n} (\mu^{(0)} P^k)_j

for all n≥1{n \ge 1} and all j∈I,{j \in I,} where (μ(0)Pk)j=∑i∈Iμi(0)pij(k).{(\mu^{(0)} P^k)_j = \sum_{i \in I} \mu^{(0)}_i p^{(k)}_{ij}.} In particular, if μ(0)=δi,{\mu^{(0)} = \delta_i,} the Dirac density in i,{i,} we have

μj(n)=1n∑k=1npij(k).\mu^{(n)}_j = \frac1n \sum_{k=1}^{n} p^{(k)}_{ij}.
15010015020000.51j = 0j = 40 < j < 4nstart i = 1; at n = 200: j = 0 gives 0.745, j = 4 gives 0.245

Figure 1. The averages μj(n)=(1/n)∑k=1npij(k){\mu^{(n)}_j = (1/n) \sum_{k=1}^{n} p^{(k)}_{ij}} for the gambler’s ruin chain on {0,1,…,N},{\{0, 1, \dots, N\},} an instance, for nn from 1 to 200, one line for each state j.{j.} The sliders set N,{N,} pp and the initial state i.{i.}

The analysis of this formula allows us to interpret the meaning of an invariant distribution. Recall that the random variable ∑k=1n1{Xk=j}\sum_{k=1}^{n} \mathbf{1}_{\{X_k = j\}} represents the number of visits to jj up to time n.{n.} Hence the random variable

1n∑k=1n1{Xk=j}\frac1n \sum_{k=1}^{n} \mathbf{1}_{\{X_k = j\}}

represents the random frequency of visits to the state jj at time n.{n.} Thus its expectation with respect to the probability Pi,{\mathbb{P}_i,}

Ei[1n∑k=1n1{Xk=j}]=1n∑k=1nPi{Xk=j}=1n∑k=1npij(k),\mathbb{E}_i\Big[ \frac1n \sum_{k=1}^{n} \mathbf{1}_{\{X_k = j\}} \Big] = \frac1n \sum_{k=1}^{n} \mathbb{P}_i\{X_k = j\} = \frac1n \sum_{k=1}^{n} p^{(k)}_{ij},

represents the average frequency of visits to the state jj at time n.{n.} Therefore we can interpret the values πj\pi_j as asymptotic average frequencies of visits to the state j.{j.}

0123456Xn00.5104080120nj = 6: frequency 0.817, average frequency 0.467 at n = 120

Figure 2. Above, a path of the gambler’s ruin chain with N=6{N = 6} and p=1/2{p = 1/2} started at X0=3,{X_0 = 3,} an instance. Below, for the state jj chosen by the slider, the frequency of visits to jj along this path up to time n,{n,} solid, and the average frequency (1/n)∑k=1np3j(k),{(1/n) \sum_{k=1}^{n} p^{(k)}_{3j},} dashed, for nn from 1 to 120. The button draws another path.

A Markov chain, even when II is finite, may have more than one invariant density, as the chain of the gambler’s ruin problem with states {0,1,…,N}{\{0, 1, \dots, N\}} shows. In this case the densities (1,0,…,0)(1, 0, \dots, 0) and (0,…,0,1),{(0, \dots, 0, 1),} and all their convex combinations

λ(1,0,…,0)+(1−λ)(0,…,0,1)=(λ,0,…,0,1−λ),λ∈[0,1],\lambda (1, 0, \dots, 0) + (1 - \lambda)(0, \dots, 0, 1) = (\lambda, 0, \dots, 0, 1 - \lambda), \qquad \lambda \in [0, 1],

are invariant. Indeed, in this chain the states 0 and NN are absorbing, that is, p00=pNN=1.{p_{00} = p_{NN} = 1.} Hence, for μ=(λ,0,…,0,1−λ),{\mu = (\lambda, 0, \dots, 0, 1 - \lambda),} the entry jj of μP\mu P is λp0j+(1−λ)pNj,{\lambda p_{0j} + (1 - \lambda) p_{Nj},} which equals μj\mu_j for every state j.{j.}

The random walk on Z\mathbb{Z}

In the case where the set II is infinite, however, a Markov chain may not admit any invariant density, as Example 5.1 shows. The random walk on Z\mathbb{Z} of the previous post, with p,q∈(0,1){p, q \in (0, 1)} and p+q=1,{p + q = 1,} jumps from each state ii to i+1{i + 1} with probability pp and to i−1{i - 1} with probability q.{q.}

Example 5.1. The random walk on Z\mathbb{Z} has no invariant density.

In Example 5.1, an invariant density (πi)i∈Z(\pi_i)_{i \in \mathbb{Z}} would satisfy πi=qπi+1+pπi−1{\pi_i = q \pi_{i+1} + p \pi_{i-1}} for all i∈Z,{i \in \mathbb{Z},} namely

q(πi+1−πi)=p(πi−πi−1).(10)q (\pi_{i+1} - \pi_i) = p (\pi_i - \pi_{i-1}). \tag{10}

Indeed, by (9) the equation for πi\pi_i collects the 2 states from which the walk jumps to i:{i{:}} pi−1,i=p{p_{i-1, i} = p} and pi+1,i=q.{p_{i+1, i} = q.} Writing πi=(p+q)πi{\pi_i = (p + q) \pi_i} and rearranging gives (10).

We begin by observing that πi+1≠πi{\pi_{i+1} \neq \pi_i} for all i∈Z.{i \in \mathbb{Z}.} Otherwise the identity (10) implies πi+1=πi{\pi_{i+1} = \pi_i} for all i,{i,} and (πi)i∈Z(\pi_i)_{i \in \mathbb{Z}} cannot be a probability density. In detail, since p,q>0,{p, q > 0,} by (10) the difference πi+1−πi{\pi_{i+1} - \pi_i} vanishes exactly when πi−πi−1{\pi_i - \pi_{i-1}} vanishes, so one vanishing difference makes all of them vanish. A constant sequence on Z\mathbb{Z} has sum 0 or +∞,{+\infty,} never 1.

We distinguish three cases: p>q,{p > q,} p=q=1/2{p = q = 1/2} and p<q.{p < q.} In the first case, from (10) we find

πi+1−πi=(p/q)i(π1−π0),\pi_{i+1} - \pi_i = (p/q)^i (\pi_1 - \pi_0),

from which lim⁡i→+∞∣πi+1−πi∣=+∞,{\lim_{i \to +\infty} |\pi_{i+1} - \pi_i| = +\infty,} contradicting the boundedness of (πi)i∈Z.{(\pi_i)_{i \in \mathbb{Z}}.} Indeed, (10) reads πi+1−πi=(p/q)(πi−πi−1),{\pi_{i+1} - \pi_i = (p/q)(\pi_i - \pi_{i-1}),} which, iterated forwards and backwards from the index 0,{0,} gives the formula, and the limit is infinite because p/q>1{p/q > 1} and π1≠π0.{\pi_1 \neq \pi_0.} The boundedness is 0≤πi≤1,{0 \le \pi_i \le 1,} which gives ∣πi+1−πi∣≤1{|\pi_{i+1} - \pi_i| \le 1} for every i.{i.} In the second case, from (10) we get the formula

πi+1−πi=π1−π0,\pi_{i+1} - \pi_i = \pi_1 - \pi_0,

from which πi=i(π1−π0)+c,{\pi_i = i (\pi_1 - \pi_0) + c,} with cc constant, which again contradicts the boundedness of (πi)i∈Z(\pi_i)_{i \in \mathbb{Z}} because π1≠π0.{\pi_1 \neq \pi_0.} The third case is similar to the first one. In detail, for p<q{p < q} the formula of the first case holds with p/q<1,{p/q < 1,} so ∣πi+1−πi∣{|\pi_{i+1} - \pi_i|} tends to +∞+\infty as i→−∞.{i \to -\infty.} Summing up, the random walk on Z\mathbb{Z} has no invariant density.

A chain on N\mathbb{N} with an explicit invariant density

The explicit computation of an invariant density, or just the proof of its existence, might not be simple. The Markov chain of Example 5.2 arises in several models. Among them are the gambler’s ruin problem when the gambler’s opponent, for example a bank, has an infinite fortune, a random walk on N,{\mathbb{N},} and the number of customers in a queue at a counter. It is a case in which one can compute explicitly the unique invariant density.

Example 5.2. Consider the Markov chain with set of states N={0,1,2,… }{\mathbb{N} = \{0, 1, 2, \dots\}} and transition matrix

P=(r0p0000⋯q1r1p100⋯0q2r2p20⋯00q3r3p3⋯000q4r4⋯⋯⋯⋯⋯⋯⋯),P = \begin{pmatrix} r_0 & p_0 & 0 & 0 & 0 & \cdots \\ q_1 & r_1 & p_1 & 0 & 0 & \cdots \\ 0 & q_2 & r_2 & p_2 & 0 & \cdots \\ 0 & 0 & q_3 & r_3 & p_3 & \cdots \\ 0 & 0 & 0 & q_4 & r_4 & \cdots \\ \cdots & \cdots & \cdots & \cdots & \cdots & \cdots \end{pmatrix},

where (pm)m≥0,{(p_m)_{m \ge 0},} (rm)m≥0(r_m)_{m \ge 0} and (qm)m>0(q_m)_{m > 0} are 3 sequences of real numbers. They satisfy pm,qm∈(0,1){p_m, q_m \in (0, 1)} and rm∈[0,1],{r_m \in [0, 1],} and

r0+p0=1,qm+rm+pm=1for all m≥1.r_0 + p_0 = 1, \qquad q_m + r_m + p_m = 1 \quad \text{for all } m \ge 1.
r0p0q10r1p1q21r2p2q32r3p3q43r4p4q54r55p5q6…π2 = p1π1 + r2π2 + q3π3

Figure 3. The chain of Example 5.2 on the states 0 to 5. Each arrow carries its transition probability; the 3 arrows into the state 2,{2,} in colour, carry the terms of the equation for π2,{\pi_2,} written under the chain.

In Example 5.2, by the equations (9) of Proposition 5.2, every invariant density (πn)n≥0(\pi_n)_{n \ge 0} satisfies

π0=r0π0+q1π1,πn=pn−1πn−1+rnπn+qn+1πn+1\begin{aligned} \pi_0 &= r_0 \pi_0 + q_1 \pi_1, \\ \pi_n &= p_{n-1} \pi_{n-1} + r_n \pi_n + q_{n+1} \pi_{n+1} \end{aligned}

for all n≥1,{n \ge 1,} besides positivity πn≥0{\pi_n \ge 0} and normalization ∑n≥0πn=1.{\sum_{n \ge 0} \pi_n = 1.} From the first equation we find

π1=1−r0q1π0=p0q1π0\pi_1 = \frac{1 - r_0}{q_1} \pi_0 = \frac{p_0}{q_1} \pi_0

and, inductively,

πn=p0⋯pn−1q1⋯qnπ0\pi_n = \frac{p_0 \cdots p_{n-1}}{q_1 \cdots q_n} \pi_0

for all n≥1.{n \ge 1.} To see this, note that 1−rn=pn+qn{1 - r_n = p_n + q_n} for n≥1,{n \ge 1,} so that the equation for πn\pi_n becomes

qn+1πn+1−pnπn=qnπn−pn−1πn−1.q_{n+1} \pi_{n+1} - p_n \pi_n = q_n \pi_n - p_{n-1} \pi_{n-1}.

The first equation says q1π1−p0π0=0,{q_1 \pi_1 - p_0 \pi_0 = 0,} so by induction qn+1πn+1=pnπn{q_{n+1} \pi_{n+1} = p_n \pi_n} for every n≥0,{n \ge 0,} and these relations give the formula. The normalization condition is fulfilled if we set

π0=(1+∑n≥1p0⋯pn−1q1⋯qn)−1\pi_0 = \Big( 1 + \sum_{n \ge 1} \frac{p_0 \cdots p_{n-1}}{q_1 \cdots q_n} \Big)^{-1}

if and only if the series

∑n≥1p0⋯pn−1q1⋯qn\sum_{n \ge 1} \frac{p_0 \cdots p_{n-1}}{q_1 \cdots q_n}

is convergent. In detail, if SS is the sum of this series, the formula for πn\pi_n gives ∑nπn=π0(1+S),{\sum_{n} \pi_n = \pi_0 (1 + S),} which equals 1 only if S<+∞{S < +\infty} and π0=(1+S)−1.{\pi_0 = (1 + S)^{-1}.} Conversely, if S<+∞,{S < +\infty,} these formulas define positive numbers with sum 1 such that qn+1πn+1=pnπn{q_{n+1} \pi_{n+1} = p_n \pi_n} for every n≥0,{n \ge 0,} and these relations give back the equations above. Therefore this condition is necessary and sufficient for the existence of an invariant density, which is necessarily unique.

01.531102030p < q: the series converges, S = 2.0000.000.250.5005101520nn

Figure 4. Example 5.2 with pm=p{p_m = p} and qm=q{q_m = q} for every m,{m,} an instance, so that the terms of the series are (p/q)n.{(p/q)^n.} Above, the partial sums of the series for nn up to 30;{30;} below, when the series converges, the invariant density πn\pi_n for nn from 0 to 20. The sliders set pp and q.{q.}