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.
Let (Xn)n≥0 be a Markov chain on the probability space (Ω,F,P) with set of states I and transition matrix P=(pij)i,j∈I. As in the previous posts, Pi is the conditional probability given X0=i, and pij(n)=Pi{Xn=j} is the entry (i,j) of the power Pn.
Definition 5.1 (Invariant probability measure). A probability measure μ on I is called invariant for the Markov chain (Xn)n≥0 if, when X0 has distribution μ, the random variable Xn has distribution μ for all n≥0.
In Definition 5.1 and below, we identify a probability measure on I with its density with respect to the counting measure on the σ-algebra of all subsets of I. This density is the collection of numbers (μi)i∈I in the interval [0,1] such that ∑i∈Iμi=1. The number μi is the measure of the set {i}, and the measure of a set of states is the sum of the numbers μi of its elements.
Proposition 5.2. A probability measure μ on I is invariant for the Markov chain (Xn)n≥0 if and only if, for every state i, we have
μi=j∈I∑μjpji,(9)
that is, the density of μ is a left eigenvector of the transition matrix with eigenvalue 1.
Proof (complete). Let μ be the probability distribution of X0. The probability distribution ν of X1 has density
νi=P{X1=i}=j∈I∑P{X0=j}pji=j∈I∑μjpji.
Indeed, the events {X0=j} with j∈I are disjoint and their union is Ω, and P{X0=j,X1=i}=P{X0=j}pji by (1.1) of the first post. Therefore, if μ is an invariant probability measure for the Markov chain (Xn)n≥0, then ν=μ and (9) holds.
Conversely, if μ is a probability measure on I satisfying (9), then Xn has probability distribution μ for all n. To see this, argue by induction on n, the case n=0 being the choice of X0. If Xn has distribution μ, then P{Xn=j,Xn+1=i}=P{Xn=j}pji by (1.1) of the first post summed over the states at the times 0,…,n−1, so the computation above, repeated at the times n and n+1, gives P{Xn+1=i}=∑jμjpji=μi by (9). ■
Summing up, a probability measure μ on I, with its density identified with the row vector (μi)i∈I, is invariant if and only if
μ=μP.
Theorem 5.3. If the set of states I is finite, then there exists at least one invariant probability measure.
Proof (complete). The set of probability densities on I
K={(μi)i∈I:0≤μi≤1 for every i,i∈I∑μi=1}
is compact, as a closed bounded subset of Rcard(I). Let μ(0)∈K. For all n≥1, the family of real numbers (μj(n))j∈I defined by
μj(n)=n1k=1∑n(i∈I∑μi(0)pij(k))
is a probability density on I. Since the set K is compact, by considering a subsequence, if necessary, we can assume that the sequence (μj(n))n≥1 is convergent for all j∈I. Defining πj=limn→∞μj(n), the collection of real numbers (πj)j∈I is a probability density on I and, moreover,
for all j∈I. This proves that the probability measure with density (πi)i∈I is invariant for the Markov chain. ■
In the proof above, the invariant probability density is obtained as a limit of subsequences of (μ(n))n≥1, where μ(0) is a density on I and
μj(n)=n1k=1∑n(μ(0)Pk)j
for all n≥1 and all j∈I, where (μ(0)Pk)j=∑i∈Iμi(0)pij(k). In particular, if μ(0)=δi, the Dirac density in i, we have
μj(n)=n1k=1∑npij(k).
Figure 1. The averages μj(n)=(1/n)∑k=1npij(k) for the gambler’s ruin chain on {0,1,…,N}, an instance, for n from 1 to 200, one line for each state j. The sliders set N,p and the initial state 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} represents the number of visits to j up to time n. Hence the random variable
n1k=1∑n1{Xk=j}
represents the random frequency of visits to the state j at time n. Thus its expectation with respect to the probability Pi,
represents the average frequency of visits to the state j at time n. Therefore we can interpret the values πj as asymptotic average frequencies of visits to the state j.
Figure 2. Above, a path of the gambler’s ruin chain with N=6 and p=1/2 started at X0=3, an instance. Below, for the state j chosen by the slider, the frequency of visits to j along this path up to time n, solid, and the average frequency (1/n)∑k=1np3j(k), dashed, for n from 1 to 120. The button draws another path.
A Markov chain, even when I is finite, may have more than one invariant density, as the chain of the gambler’s ruin problem with states {0,1,…,N} shows. In this case the densities (1,0,…,0) and (0,…,0,1), and all their convex combinations
λ(1,0,…,0)+(1−λ)(0,…,0,1)=(λ,0,…,0,1−λ),λ∈[0,1],
are invariant. Indeed, in this chain the states 0 and N are absorbing, that is, p00=pNN=1. Hence, for μ=(λ,0,…,0,1−λ), the entry j of μP is λp0j+(1−λ)pNj, which equals μj for every state j.
In the case where the set I is infinite, however, a Markov chain may not admit any invariant density, as Example 5.1 shows. The random walk on Z of the previous post, with p,q∈(0,1) and p+q=1, jumps from each state i to i+1 with probability p and to i−1 with probability q.
Example 5.1. The random walk on Z has no invariant density.
In Example 5.1, an invariant density (πi)i∈Z would satisfy πi=qπi+1+pπi−1 for all i∈Z, namely
q(πi+1−πi)=p(πi−πi−1).(10)
Indeed, by (9) the equation for πi collects the 2 states from which the walk jumps to i:pi−1,i=p and pi+1,i=q. Writing πi=(p+q)πi and rearranging gives (10).
We begin by observing that πi+1=πi for all i∈Z. Otherwise the identity (10) implies πi+1=πi for all i, and (πi)i∈Z cannot be a probability density. In detail, since p,q>0, by (10) the difference πi+1−πi vanishes exactly when πi−πi−1 vanishes, so one vanishing difference makes all of them vanish. A constant sequence on Z has sum 0 or +∞, never 1.
We distinguish three cases: p>q,p=q=1/2 and p<q. In the first case, from (10) we find
πi+1−πi=(p/q)i(π1−π0),
from which limi→+∞∣πi+1−πi∣=+∞, contradicting the boundedness of (πi)i∈Z. Indeed, (10) reads πi+1−πi=(p/q)(πi−πi−1), which, iterated forwards and backwards from the index 0, gives the formula, and the limit is infinite because p/q>1 and π1=π0. The boundedness is 0≤πi≤1, which gives ∣πi+1−πi∣≤1 for every i. In the second case, from (10) we get the formula
πi+1−πi=π1−π0,
from which πi=i(π1−π0)+c, with c constant, which again contradicts the boundedness of (πi)i∈Z because π1=π0. The third case is similar to the first one. In detail, for p<q the formula of the first case holds with p/q<1, so ∣πi+1−πi∣ tends to +∞ as i→−∞. Summing up, the random walk on Z has no 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, 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,…} and transition matrix
where (pm)m≥0,(rm)m≥0 and (qm)m>0 are 3 sequences of real numbers. They satisfy pm,qm∈(0,1) and rm∈[0,1], and
r0+p0=1,qm+rm+pm=1for all m≥1.
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, in colour, carry the terms of the equation for π2, written under the chain.
for all n≥1, besides positivity πn≥0 and normalization ∑n≥0πn=1. From the first equation we find
π1=q11−r0π0=q1p0π0
and, inductively,
πn=q1⋯qnp0⋯pn−1π0
for all n≥1. To see this, note that 1−rn=pn+qn for n≥1, so that the equation for πn becomes
qn+1πn+1−pnπn=qnπn−pn−1πn−1.
The first equation says q1π1−p0π0=0, so by induction qn+1πn+1=pnπn for every n≥0, and these relations give the formula. The normalization condition is fulfilled if we set
π0=(1+n≥1∑q1⋯qnp0⋯pn−1)−1
if and only if the series
n≥1∑q1⋯qnp0⋯pn−1
is convergent. In detail, if S is the sum of this series, the formula for πn gives ∑nπn=π0(1+S), which equals 1 only if S<+∞ and π0=(1+S)−1. Conversely, if S<+∞, these formulas define positive numbers with sum 1 such that qn+1πn+1=pnπn for every n≥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.
Figure 4.Example 5.2 with pm=p and qm=q for every m, an instance, so that the terms of the series are (p/q)n. Above, the partial sums of the series for n up to 30; below, when the series converges, the invariant density πn for n from 0 to 20. The sliders set p and q.