Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Every irreducible and aperiodic Markov Chain on a finite state space exhibits astonishing regularity after it has run for a while. The proof of the convergence theorem below is beyond the scope of this course, but in examples you have seen the result by computation. All the results are true in greater generality for some classes of Markov Chains on infinitely many states.

🎥 See More
Loading...

10.3.1Convergence to Stationarity

Let X0,X1,X_0, X_1, \ldots be an irreducible, aperiodic Markov chain on a finite state space SS. Then for all states ii and jj,

Pn(i,j)π(j)   as nP_n(i, j) \to \pi(j) ~~~ \text{as } n \to \infty

In other words, for every ii and jj in SS, the nn-step transition probability from ii to jj converges to a limit that does not depend on ii. Moreover,

  • π(j)>0\pi(j) > 0 for all states jj, and

  • jSπ(j)=1\sum_{j \in S} \pi(j) = 1

That is, as nn \to \infty, every row of the nn-step transition matrix Pn\mathbb{P}^n converges to the same vector π\pi which is a probability distribution in which all the terms are positive.

10.3.2Properties of the Limit

In this section we will establish the following results. All of them are useful for calculation and for understanding the long run behavior of Markov chains.

(i) The row vector π\pi is the unique probability distribution that solves the balance equations πP=π\pi \mathbb{P} = \pi. Every other solution has the form cπc\pi for some constant cc.

(ii) If for some nn the distribution of XnX_n is π\pi, then the distribution of XmX_m is also π\pi for all m>nm > n. Thus π\pi is called the stationary or steady state distribution of the chain.

(iii) For each state jj, the jjth entry of the π\pi vector π(j)\pi(j) is the expected long run proportion of time the chain spends at jj.

We will assume that the convergence theorem is true; you have observed in numerically in examples. The other properties follow rather easily. In the remainder of this section we will establish the properties and see how they are used.

🎥 See More
Loading...

10.3.3Balance Equations

In our example of the sticky reflecting walk, we found the steady state distribution by computation: we simply computed the nn-step transition matrix for large nn and saw that eventually all the rows were the same. The distribution common to all the rows was the steady state distribution.

But there is also a simple analytical way of finding the steady state distribution. To see this, let n0n \ge 0 and let ii and jj be two states. Then

Pn+1(i,j)=kSPn(i,k)P(k,j)P_{n+1}(i, j) = \sum_{k \in S} P_n(i, k)P(k, j)

Therefore

limnPn+1(i,j)=limnkSPn(i,k)P(k,j)=kS(limnPn(i,k))P(k,j)\begin{align*} \lim_{n \to \infty} P_{n+1}(i, j) &= \lim_{n \to \infty} \sum_{k \in S} P_n(i, k)P(k, j) \\ \\ &= \sum_{k \in S} \big( \lim_{n \to \infty} P_n(i, k) \big) P(k, j) \end{align*}

We can exchange the limit and the sum because SS is finite. Now apply the theorem on convergence to stationarity:

π(j)=kSπ(k)P(k,j)\pi(j) = \sum_{k \in S} \pi(k)P(k, j)

These are called the balance equations. There is one equation for each state jj.

In matrix notation, if you think of π\pi as a row vector, these equations become

π=πP     or, as we will often say it,     πP=π\pi = \pi \mathbb{P} ~~~~~ \text{or, as we will often say it,} ~~~~~ \pi\mathbb{P} = \pi

The balance equations help us compute π\pi without taking limits.

In a later chapter we will see how the term balance arises. For now, let’s focus on solving the equations.

10.3.4Uniqueness

It’s not very hard to show that if a probability distribution solves the balance equations, then it has to be π\pi, the limit of the marginal distributions of XnX_n. We won’t do the proof; it essentially repeats the steps we took to derive the balance equations. You should just be aware that an irreducible, aperiodic, finite state Markov Chain has exactly one stationary distribution.

This is particularly helpful if you happen to guess a solution to the balance equations. If the solution that you have guessed is a probability distribution, you have found the stationary distribution of the chain.

10.3.5Solving the Balance Equations

The zero vector solves the balance equations, but it’s not a probability distribution.

To find non-zero solutions, it is tempting to rewrite the balance equations as π(IP)=0\pi(\mathbb{I} - \mathbb{P}) = 0 where I\mathbb{I} is the identity matrix, and try to invert IP\mathbb{I} - \mathbb{P}. But that doesn’t work. Each row of P\mathbb{P} sums to 1, and hence each row of IP\mathbb{I} - \mathbb{P} sums to 0, which means that IP\mathbb{I} - \mathbb{P} is not invertible.

So there are multiple solutions of the balance equations. We can see this easily by noting that if any vector solves the balance equations, then 10 times that vector also solves them.

Our job is to find the solution that is also a probability distribution. That’s the steady state vector π\pi.

Let ss denote the number of elements in the state space SS. Then π\pi is a row vector of length ss. The jjth element of π\pi is π(j)\pi(j) and corresponds to the jjth element of the state space.

Two key observations help us solve the balance equations.

  • The equations say that for each state jj, π(j)\pi(j) is equal to the dot product of π\pi and the jjth column of P\mathbb{P}.

  • There are therefore ss equations with the additional condition that jSπ(j)=1\sum_{j \in S} \pi(j) = 1.

In many examples, there is an efficient way of solving these equations.

  • Try to manipulate each balance equation so that you can write each π(j)\pi(j) in terms of the same element of π\pi. For example, you might be able to simplify the equations to see that π=[π(1),c2π(1),c3π(1),,csπ(1)]\pi = [\pi(1), c_2\pi(1), c_3\pi(1), \ldots, c_s\pi(1)] where c2,c3,,csc_2, c_3, \ldots, c_s are constants you have determined from the balance equations.

  • Then solve for that key element of π\pi by using the fact that the elements of π\pi sum to 1. In the example above, (1+c1+c2++cs)π(1)=1(1 + c_1 + c_2 + \cdots + c_s)\pi(1) = 1, so you can solve for π(1)\pi(1). By plugging this value into the expression for π\pi above, you get the entire vector π\pi.

Here is an example of carrying out this process.

10.3.6Stationary Distribution of Sticky Reflecting Walk

We studied this in an earlier section. The transition diagram is

Lazy Circle Walk

Here is the transition matrix P\mathbb{P}.

reflecting_walk
Loading...

The MarkovChain method steady_state returns the stationary distribution π\pi. You saw earlier that this is the limit of the rows of P\mathbb{P}.

reflecting_walk.steady_state()
Loading...

We could also solve for π\pi using the balance equations. While this might seem superfluous given that Python has already given us π\pi, it is good practice for when transition matrices are larger and not numerical.

According to the balance equations, π(1)\pi(1) is the dot product of π\pi and Column 1 of P\mathbb{P}. So

π(1) = π(1)0.5 + π(2)0.25\pi(1) ~ = ~ \pi(1)\cdot 0.5 ~ + ~ \pi(2) \cdot 0.25

Rearrange this to write π(2)\pi(2) in terms of π(1)\pi(1):

π(2)=2π(1)\pi(2) = 2\pi(1)

Follow the same process with the next equation.

π(2) = 0.5π(1)+0.5π(2)+0.25π(3)\pi(2) ~ = ~ 0.5\pi(1) + 0.5\pi(2) + 0.25\pi(3)

Rearrange this and plug in π(2)=2π(1)\pi(2) = 2\pi(1) to get

π(3)=2π(1)\pi(3) = 2\pi(1)

Similarly, you will get π(4)=2π(1)\pi(4) = 2\pi(1) and π(5)=π(1)\pi(5) = \pi(1).

So π\pi can be written entirely in terms of π(1)\pi(1):

π=[π(1),2π(1),2π(1),2π(1),π(1)]\pi = [ \pi(1), 2\pi(1), 2\pi(1), 2\pi(1), \pi(1) ]

Now use the fact that π\pi sums to 1. By the formula above, the total is 8π(1)8\pi(1), so π(1)=1/8\pi(1) = 1/8. This gives us the whole distribution:

π=[18,28,28,28,18]\pi = \big[ \frac{1}{8}, \frac{2}{8}, \frac{2}{8}, \frac{2}{8}, \frac{1}{8} \big]
🎥 See More
Loading...

10.3.7Steady State

The steady state isn’t an element of the state space SS. It’s the condition of the chain after it has been run for a long time. Let’s examine this further.

The theorem on convergence to stationarity says that the chain approaches the steady state as nn gets large. If it actually achieves the steady state, that is, if the distribution of XnX_n is equal to π\pi for some nn, then it stays in that state, for the following reason.

P(Xn+1=j)=iSP(Xn=i)P(i,j)=iSπ(i)P(i,j)=π(j)P(X_{n+1} = j) = \sum_{i \in S} P(X_n = i)P(i, j) = \sum_{i \in S} \pi(i)P(i, j) = \pi(j)

by the balance equations. Now use induction.

In particular, if you start the chain with its stationary distribution π\pi, then the distribution of XnX_n is equal to π\pi for every nn.

10.3.8Expected Long Run Proportion of Time

Suppose you run a chain for a long time. Then the chance that the chain is at state jj is approximately π(j)\pi(j) no matter where the chain started. So in the long run, the chain is expected to spend a proportion of π(j)\pi(j) of its time at the state jj.

Formally, let jj be a state, and let Im(j)I_m(j) be the indicator of the event {Xm=j}\{X_m = j\}. The proportion of time the chain spends at jj, from time 1 through time nn, is

1nm=1nIm(j)\frac{1}{n} \sum_{m=1}^n I_m(j)

Therefore, the expected proportion of time the chain spends at jj, given that it started at ii, is

1nm=1nE(Im(j)X0=i)=1nm=1nP(Xm=jX0=i)=1nm=1nPm(i,j)\frac{1}{n} \sum_{m=1}^n E(I_m(j) \mid X_0 = i) = \frac{1}{n} \sum_{m=1}^n P(X_m = j \mid X_0 = i) = \frac{1}{n} \sum_{m=1}^n P_m(i, j)

Now recall a property of convergent sequences of real numbers:

  • If xnxx_n \to x as nn \to \infty, then the sequence of averages also converges to xx. That is,

1nm=1nxmx   as n\frac{1}{n} \sum_{m=1}^n x_m \to x ~~~ \text{as } n \to \infty

Take xn=Pn(i,j)x_n = P_n(i, j). Then by the theorem on convergence to stationarity,

Pn(i,j)π(j)   as nP_n(i, j) \to \pi(j) ~~~ \text{as } n \to \infty

and hence the averages also converge:

1nm=1nPm(i,j)π(j)   as n\frac{1}{n} \sum_{m=1}^n P_m(i, j) \to \pi(j) ~~~ \text{as } n \to \infty

Thus the long run expected proportion of time the chain spends in state jj is π(j)\pi(j), where π\pi is the stationary distribution of the chain.

10.3.9Sticky Random Walk on a Circle

Now let the state space be five points arranged on a circle. Suppose the process starts at Point 1, and at each step either stays in place with probability 0.5 (and thus is sticky), or moves to one of the two neighboring points with chance 0.25 each, regardless of the other moves.

In other words, this walk is just the same as the sticky reflecting walk, except that 151 \rightarrow 5 and 515 \rightarrow 1 transitions are both possible. This transition behavior can be summed up in a transition diagram. Notice that the transition behavior is the same for all the states.

Lazy Circle Walk

At every step, the next move is determined by a random choice from among three options and by the chain’s current location, not on how it got to that location. So the process is a Markov chain. Let’s call it X0,X1,X2,X_0, X_1, X_2, \ldots and define its transition matrix.

s = np.arange(1, 6)

def circle_walk_probs(i, j):
        if i-j == 0:
            return 0.5
        elif abs(i-j) == 1:
            return 0.25
        elif abs(i-j) == 4:
            return 0.25
        else:
            return 0   
        
circle_walk = MarkovChain.from_transition_function(s, circle_walk_probs)
circle_walk
Loading...

Because of the symmetry of the transition behavior across all the states, in the long run no state should be occupied more than any other state. Hence all the π(j)\pi(j)'s should be equal. This is confirmed by steady_state, and you can also confirm it by checking that the vector π=[0.2,0.2,0.2,0.2,0.2]\pi = [0.2, 0.2, 0.2, 0.2, 0.2] solves the balance equations. Remember that the steady state distribution is unique, so there is nothing more to check.

circle_walk.steady_state()
Loading...