The equilibrium

Run a Markov chain long enough and the distribution over states stops changing. No matter where you started.

What do you think?
A Markov chain has states A, B, C. You start at A and run it for 10,000 steps. Your friend starts at C and runs it for 10,000 steps. Will you visit the states in the same proportions?

Stationary distribution

Stationary Distribution

A probability vector π\boldsymbol\pi is a stationary distribution of a Markov chain with transition matrix PP if: π=πP\boldsymbol\pi = \boldsymbol\pi P and iπi=1\sum_i \pi_i = 1. Once the chain reaches this distribution, it stays there forever.

Think of it as a balance condition: the probability flowing into each state equals the probability flowing out.

Finding the stationary distribution

Weather chain stationary distribution
{πS=0.8πS+0.4πRπR=0.2πS+0.6πR\begin{cases} \pi_S = 0.8\pi_S + 0.4\pi_R \\ \pi_R = 0.2\pi_S + 0.6\pi_R \end{cases}
Write the balance equations π = πP
Step 1 of 4

In the long run, it's sunny 2/3 of the time and rainy 1/3 — regardless of today's weather.

Watch it converge

Pour "probability fluid" into the nodes. Watch it flow through the transitions until the levels stabilize at the stationary distribution:

Stationary Distribution Flow
Start from
0.2000.000Sun1.0000Rain0.0000π target
Step
0
π(Sun) target
0.6667
π(Rain) target
0.3333
|Error|
0.333333

The convergence theorem

Convergence Theorem

If a Markov chain is irreducible and aperiodic, then:

  1. A unique stationary distribution π\boldsymbol\pi exists.
  2. For any starting distribution, P(Xn=j)πjP(X_n = j) \to \pi_j as nn \to \infty.
  3. The fraction of time spent in state jj converges to πj\pi_j.

Reducible chains may have multiple stationary distributions. Periodic chains cycle rather than converge. Both conditions (irreducible + aperiodic) are needed.

Detailed balance

A stronger condition than stationarity:

Detailed Balance

A distribution π\boldsymbol\pi satisfies detailed balance (is "reversible") if: πipij=πjpjifor all i,j\pi_i \, p_{ij} = \pi_j \, p_{ji} \quad \text{for all } i, j The flow from ii to jj equals the flow from jj to ii.

Detailed balance implies stationarity (but not vice versa). MCMC algorithms are built on it.

Applications

DomainStatesTransitions
Page rankingWeb pagesLinks between pages
GeneticsAllelesMutation + selection
Speech recognitionPhonemesLanguage model
FinanceMarket regimesBull ↔ Bear transitions
Board gamesBoard positionsDice rolls + moves

Practice problems

The stationary distribution satisfies π = πP. What does this mean in words? (one word)
For the weather chain (π_S = 2/3, π_R = 1/3), what fraction of a 300-day span is rainy? (whole number)

Summary

ConceptKey Formula
Stationary distributionπ=πP\boldsymbol\pi = \boldsymbol\pi P, πi=1\sum \pi_i = 1
ConvergenceIrreducible + aperiodic → unique π\boldsymbol\pi
Time averagesFraction in state jjπj\pi_j
Detailed balanceπipij=πjpji\pi_i p_{ij} = \pi_j p_{ji}

The stationary distribution is the Markov chain's version of the LLN. Just as sample averages converge to the true mean, state visit frequencies converge to π\boldsymbol\pi.

What's next

The stationary distribution is a theoretical target. But what if we can't solve π=πP\boldsymbol\pi = \boldsymbol\pi P analytically? MCMC algorithms construct a Markov chain whose stationary distribution is exactly the distribution we want to sample from.