Markov Chains — Transition Matrices and Stationary Distributions

⚡ Key Takeaways

A Markov chain is a stochastic process whose future evolution depends only on its present state, not its history. Its dynamics are encoded in a transition matrix PP whose entries are conditional probabilities, and its long-run behaviour is captured by a stationary distribution π\pi satisfying πP=π\pi P = \pi. Applies to: queueing theory, PageRank, statistical physics, genetics, MCMC sampling. Core machinery developed by Andrey Markov (1906); convergence theory matured through the 20th century.

💡 The Core Insight

The present screens off the past. Because the future depends on the past only through the current state, the whole evolution reduces to linear algebra: distributions are row vectors, one time step is right-multiplication by PP, and equilibrium is a left eigenvector of PP with eigenvalue 11. Probability theory becomes the spectral theory of a stochastic matrix.

Formal Statement

DefinitionMarkov Chain and the Markov Property

Let SS be a countable set (the state space). A sequence of SS-valued random variables (Xn)n≥0(X_n)_{n\ge 0} is a (time-homogeneous) Markov chain if for all n≥0n\ge 0 and all states i0,…,in−1,i,ji_0, \dots, i_{n-1}, i, j with positive probability,

1
P(Xn+1=j∣Xn=i, Xn−1=in−1,…,X0=i0)=P(Xn+1=j∣Xn=i)=Pij.\quad \mathbb{P}(X_{n+1}=j \mid X_n=i,\, X_{n-1}=i_{n-1},\dots,X_0=i_0) = \mathbb{P}(X_{n+1}=j \mid X_n=i) = P_{ij}.

Derivation hint: this is the definitional axiom; "time-homogeneous" means the right-hand side is independent of nn, so a single matrix PP suffices. Here PijP_{ij} is the transition probability from ii to jj, and P=(Pij)P = (P_{ij}) is the transition matrix. The initial distribution is the row vector μ(0)\mu^{(0)} with μi(0)=P(X0=i)\mu^{(0)}_i = \mathbb{P}(X_0 = i).

DefinitionStochastic Matrix

A matrix PP is row-stochastic (or simply stochastic) if

2
Pij≥0for all i,j,∑j∈SPij=1for all i.\quad P_{ij} \ge 0 \quad \text{for all } i,j, \qquad \sum_{j\in S} P_{ij} = 1 \quad \text{for all } i.

Derivation hint: each row is the conditional distribution of Xn+1X_{n+1} given Xn=iX_n=i, so it must be a probability vector — nonnegative and summing to one. Every transition matrix is stochastic, and conversely every stochastic matrix with a chosen initial distribution defines a Markov chain.

Definitionnn-Step Transition Matrix and Distribution Evolution

Write Pij(n)=P(Xn=j∣X0=i)P^{(n)}_{ij} = \mathbb{P}(X_n = j \mid X_0 = i) for the nn-step transition probability. Then

3
P(n)=Pn,μ(n)=μ(0)Pn,\quad P^{(n)} = P^n, \qquad \mu^{(n)} = \mu^{(0)} P^n,

Derivation hint: iterate the Chapman–Kolmogorov equation P(m+n)=P(m)P(n)P^{(m+n)} = P^{(m)}P^{(n)}; the row vector μ(n)\mu^{(n)} of marginal probabilities evolves by right-multiplication, by the law of total probability. where μj(n)=P(Xn=j)\mu^{(n)}_j = \mathbb{P}(X_n = j) is the distribution at time nn.

TheoremChapman–Kolmogorov Equations

For all m,n≥0m,n\ge 0 and all states i,ji,j,

4
Pij(m+n)=∑k∈SPik(m) Pkj(n).\quad P^{(m+n)}_{ij} = \sum_{k\in S} P^{(m)}_{ik}\, P^{(n)}_{kj}.

Derivation hint: condition on the intermediate state Xm=kX_m = k and use the Markov property to split the path at time mm; this is exactly matrix multiplication Pm+n=PmPnP^{m+n}=P^m P^n.

DefinitionStationary Distribution

A probability row vector π=(πi)i∈S\pi = (\pi_i)_{i\in S} (so πi≥0\pi_i \ge 0, ∑iπi=1\sum_i \pi_i = 1) is a stationary distribution (or invariant distribution) of PP if

5
πP=π,i.e.πj=∑i∈Sπi Pij  for all j.\quad \pi P = \pi, \quad\text{i.e.}\quad \pi_j = \sum_{i\in S} \pi_i\, P_{ij} \ \text{ for all } j.

Derivation hint: require that if X0∼πX_0 \sim \pi then X1∼πX_1 \sim \pi; by equation [3] this is exactly πP=π\pi P = \pi, making π\pi a left eigenvector of PP for eigenvalue 11. If X0∼πX_0 \sim \pi, then Xn∼πX_n \sim \pi for all nn: the chain is in statistical equilibrium.

DefinitionIrreducibility, Period, Recurrence
  • The chain is irreducible if every state can be reached from every other: for all i,ji,j there exists nn with Pij(n)>0P^{(n)}_{ij} > 0.
  • The period of state ii is d(i)=gcd⁡{n≥1:Pii(n)>0}d(i) = \gcd\{n \ge 1 : P^{(n)}_{ii} > 0\}. The chain is aperiodic if d(i)=1d(i)=1 for all ii (in an irreducible chain the period is a common value).
  • A state is recurrent if P(return to i∣X0=i)=1\mathbb{P}(\text{return to } i \mid X_0 = i) = 1, and positive recurrent if the mean return time mi=E[Ti∣X0=i]m_i = \mathbb{E}[T_i \mid X_0=i] is finite, where Ti=min⁡{n≥1:Xn=i}T_i = \min\{n\ge 1 : X_n = i\}.
TheoremExistence, Uniqueness, and Convergence — the Fundamental Theorem

Let PP be the transition matrix of an irreducible Markov chain on SS. 1. A stationary distribution π\pi exists iff the chain is positive recurrent; when it exists it is unique and satisfies πi>0\pi_i > 0 for all ii. 2. (Return-time formula) πi=1mi\displaystyle \pi_i = \frac{1}{m_i}, the reciprocal of the mean return time to ii. 3. (Convergence) If in addition the chain is aperiodic, then for every initial distribution μ(0)\mu^{(0)},

6
lim⁡n→∞μ(0)Pn=π,equivalentlylim⁡n→∞Pij(n)=πj  for all i,j.\quad \lim_{n\to\infty} \mu^{(0)} P^n = \pi, \qquad \text{equivalently} \quad \lim_{n\to\infty} P^{(n)}_{ij} = \pi_j \ \text{ for all } i,j.

Derivation hint: aperiodicity + irreducibility + finite state space makes some power PNP^N strictly positive; the Perron–Frobenius theorem then forces a simple dominant eigenvalue 11 with all other eigenvalues strictly inside the unit disk, so PnP^n converges to the rank-one projection 1π\mathbf{1}\pi.

Why It Holds / Derivation

ProofExistence of π\pi on a finite irreducible chain

We sketch the finite-state argument, the most important undergraduate case. 1. Stochasticity gives eigenvalue 1. Since each row of PP sums to 11, the all-ones column vector 1\mathbf{1} satisfies P1=1P\mathbf{1} = \mathbf{1}. Thus 11 is an eigenvalue of PP (a right eigenvector). A matrix and its transpose share eigenvalues, so there exists a left eigenvector vv with vP=vvP = v. 2. Sign control via Perron–Frobenius. Irreducibility means PP (viewed as a nonnegative matrix) is irreducible in the matrix sense. The Perron–Frobenius theorem guarantees that the spectral radius equals 11, is a simple eigenvalue, and its left eigenvector vv can be taken with all entries strictly positive. 3. Normalisation. Since vi>0v_i>0 and ∑ivi\sum_i v_i is finite (finite state space), set πi=vi/∑kvk\pi_i = v_i / \sum_k v_k. Then π\pi is a probability vector with πP=π\pi P = \pi, establishing existence. ■\quad\blacksquare

∎
ProofUniqueness and the return-time formula

1. Uniqueness. Perron–Frobenius makes eigenvalue 11 simple, so its eigenspace is one-dimensional; the only probability vector in it is π\pi. Hence π\pi is unique. 2. Return-time identity. Define the expected number of visits to ii between consecutive visits to a fixed reference state. The renewal-reward theorem says the long-run fraction of time in state ii equals (expected visits to ii per cycle)/(expected cycle length). Choosing the cycle to be a return to ii itself gives one visit per cycle of mean length mim_i, so the long-run frequency is 1/mi1/m_i. By the ergodic theorem for Markov chains this frequency equals πi\pi_i. Hence πi=1/mi\pi_i = 1/m_i, and finiteness of mim_i (positive recurrence) is exactly the condition for πi>0\pi_i > 0. ■\quad\blacksquare

∎
ProofConvergence under aperiodicity (coupling sketch)

1. Construct two coupled copies. Run a chain XnX_n started from μ(0)\mu^{(0)} and an independent chain YnY_n started from π\pi, evolving by the same PP. 2. Coupling time. Irreducibility + aperiodicity guarantees the joint chain (Xn,Yn)(X_n, Y_n) is irreducible on S×SS \times S and reaches the diagonal {(s,s)}\{(s,s)\} with probability 11 in finite expected time τ\tau. 3. Once coupled, stay coupled. After τ\tau, run Xn=YnX_n = Y_n identically. Since Yn∼πY_n \sim \pi for all nn,

∣P(Xn=j)−πj∣≤P(τ>n)→0.\big| \mathbb{P}(X_n = j) - \pi_j \big| \le \mathbb{P}(\tau > n) \to 0.

This gives total-variation convergence μ(0)Pn→π\mu^{(0)}P^n \to \pi, proving equation [6]. Aperiodicity is essential: without it τ\tau may be infinite because the two chains never align in phase. ■\quad\blacksquare

∎
mathematician · Andrey Andreyevich Markov | 1856–1922

A student of Pafnuty Chebyshev at St. Petersburg, Markov introduced his chains in 1906 to extend the law of large numbers and the central limit theorem to dependent random variables — refuting the then-common belief that independence was indispensable. In a celebrated 1913 study he applied the method to the sequence of vowels and consonants in Pushkin's Eugene Onegin, arguably the first quantitative analysis of text as a stochastic process. A fierce, principled man, Markov publicly resigned privileges in protest of Tsarist politics. His chains became foundational to twentieth-century probability, information theory, and computation.

Building Intuition

🧠 Intuition

Think of a frog hopping among lily pads. The transition matrix PP tells you, from whichever pad the frog sits on right now, the odds of each next pad — and crucially the frog has no memory of how it got there. If you place a large cloud of frogs according to distribution μ(0)\mu^{(0)} and let them all hop once, the new cloud is μ(0)P\mu^{(0)}P; hop again, μ(0)P2\mu^{(0)}P^2. The stationary distribution π\pi is the special cloud shape that hops to itself — pour the frogs out in proportion π\pi and the population picture never changes, even though every individual frog keeps moving. The convergence theorem says that any starting cloud, after enough hops, relaxes to this same shape π\pi — the system forgets its initial condition. And πi=1/mi\pi_i = 1/m_i has a beautifully concrete meaning: the busiest pads (high πi\pi_i) are exactly the ones the frog returns to fastest.

Figure
Two-state Markov chain and its convergence to the stationary distribution

```svg

Two-state chain: P=[[0.7,0.3],[0.4,0.6]] A B 0.3 0.4 0.7 0.6 n P(A) π₀=0.571 start X₀=A

```

Worked Examples

ExampleTwo-state chain — solving πP=π\pi P = \pi

Given: S={A,B}S = \{A, B\} with

P=(0.70.30.40.6).P = \begin{pmatrix} 0.7 & 0.3 \\ 0.4 & 0.6 \end{pmatrix}.

Find the stationary distribution.

Steps. 1. Write π=(πA,πB)\pi = (\pi_A, \pi_B) and solve πP=π\pi P = \pi:

πA=0.7πA+0.4πB,πB=0.3πA+0.6πB.\pi_A = 0.7\pi_A + 0.4\pi_B, \qquad \pi_B = 0.3\pi_A + 0.6\pi_B.

2. The first equation gives 0.3πA=0.4πB⇒πA=43πB0.3\pi_A = 0.4\pi_B \Rightarrow \pi_A = \tfrac{4}{3}\pi_B. (The two equations are dependent — expected, since rows of P−IP-I are linearly dependent.) 3. Apply normalisation πA+πB=1\pi_A + \pi_B = 1: 43πB+πB=1⇒73πB=1⇒πB=37\tfrac{4}{3}\pi_B + \pi_B = 1 \Rightarrow \tfrac{7}{3}\pi_B = 1 \Rightarrow \pi_B = \tfrac{3}{7}, so πA=47\pi_A = \tfrac{4}{7}. 4. Check via return time: mA=1/πA=7/4=1.75m_A = 1/\pi_A = 7/4 = 1.75 steps mean return time to AA.

π=(47, 37)≈(0.571, 0.429) (dimensionless probabilities)\boxed{\pi = \left(\tfrac{4}{7},\ \tfrac{3}{7}\right) \approx (0.571,\ 0.429) \ \text{(dimensionless probabilities)}}
ExampleWeather chain — long-run fractions and a finite-step forecast

Given: States {Sunny,Rainy}\{\text{Sunny}, \text{Rainy}\} with

P=(0.90.10.50.5),P = \begin{pmatrix} 0.9 & 0.1 \\ 0.5 & 0.5 \end{pmatrix},

today is Sunny, i.e. μ(0)=(1,0)\mu^{(0)} = (1, 0).

Steps. 1. Two-step forecast: μ(1)=μ(0)P=(0.9,0.1)\mu^{(1)} = \mu^{(0)}P = (0.9, 0.1). Then

μ(2)=μ(1)P=(0.9⋅0.9+0.1⋅0.5,  0.9⋅0.1+0.1⋅0.5)=(0.86, 0.14).\mu^{(2)} = \mu^{(1)}P = (0.9\cdot 0.9 + 0.1\cdot 0.5,\ \ 0.9\cdot 0.1 + 0.1\cdot 0.5) = (0.86,\ 0.14).

So P(Sunny in 2 days)=0.86\mathbb{P}(\text{Sunny in 2 days}) = 0.86. 2. Stationary distribution: solve πS=0.9πS+0.5πR\pi_S = 0.9\pi_S + 0.5\pi_R, giving 0.1πS=0.5πR0.1\pi_S = 0.5\pi_R, so πS=5πR\pi_S = 5\pi_R. Normalise: 6πR=16\pi_R = 1, πR=16\pi_R = \tfrac16, πS=56\pi_S = \tfrac56. 3. Interpretation: in the long run roughly 83.3%83.3\% of days are sunny, independent of today's weather (chain is irreducible and aperiodic — note PSS>0P_{SS}>0 kills periodicity). 4. Mean return time to Rain: mR=1/πR=6m_R = 1/\pi_R = 6 days.

π=(56, 16)≈(0.833, 0.167);P(sunny in 2 days)=0.86\boxed{\pi = \left(\tfrac56,\ \tfrac16\right) \approx (0.833,\ 0.167); \quad \mathbb{P}(\text{sunny in 2 days})=0.86}

Common Misconceptions

⚠️ Common mistake

A stationary distribution is not a fixed state. The chain does not stop at π\pi. Individual trajectories keep jumping forever; it is the probability distribution over states that is frozen. Likewise, "πP=π\pi P = \pi" is a statement about the row vector π\pi (a left eigenvector), not about P1=1P\mathbf{1}=\mathbf{1} (the right eigenvector 1\mathbf{1}, which every stochastic matrix has trivially). Confusing left and right eigenvectors is the single most common error.

⚠️ Common mistake

Existence of π\pi does not guarantee convergence. A unique stationary distribution can exist while μ(0)Pn\mu^{(0)}P^n fails to converge — this happens for periodic chains. Convergence in equation [6] requires aperiodicity in addition to irreducibility and positive recurrence. The time-average (Cesàro mean) 1n∑k<nμ(0)Pk\frac1n\sum_{k<n}\mu^{(0)}P^k always converges to π\pi for irreducible positive-recurrent chains, but the instantaneous distribution may oscillate forever.

CounterexampleA periodic chain with no convergence

Take S={1,2}S=\{1,2\} and the deterministic swap

P=(0110).P = \begin{pmatrix} 0 & 1 \\ 1 & 0 \end{pmatrix}.

This chain is irreducible and its unique stationary distribution is π=(12,12)\pi = (\tfrac12,\tfrac12) (check: πP=π\pi P = \pi). But starting from μ(0)=(1,0)\mu^{(0)}=(1,0) we get μ(1)=(0,1)\mu^{(1)}=(0,1), μ(2)=(1,0)\mu^{(2)}=(1,0), …\dots — the distribution oscillates with period 22 and never converges to (12,12)(\tfrac12,\tfrac12). The period is gcd⁡{2,4,6,… }=2\gcd\{2,4,6,\dots\}=2, so the chain is not aperiodic and equation [6] does not apply. The Cesàro average, however, does tend to (12,12)(\tfrac12,\tfrac12).

CounterexampleNon-uniqueness when reducibility fails

Take S={1,2,3}S=\{1,2,3\} with two absorbing states and one transient:

P=(10001012120).P = \begin{pmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ \tfrac12 & \tfrac12 & 0 \end{pmatrix}.

This chain is reducible: states 11 and 22 are absorbing. Every mixture π=(a,1−a,0)\pi = (a, 1-a, 0) with a∈[0,1]a\in[0,1] satisfies πP=π\pi P=\pi, so the stationary distribution is far from unique. Irreducibility in the Fundamental Theorem is exactly what rules this out.

Connections

connection

Markov chains sit at a crossroads of several theories. The matrix machinery is pure Linear Algebra: stationary distributions are left eigenvectors and convergence rates are governed by the second-largest eigenvalue modulus (the spectral gap). Existence and positivity flow from the Perron–Frobenius Theorem for nonnegative matrices. The convergence proof relies on Coupling of Stochastic Processes and on ergodic ideas shared with Ergodic Theory. The continuous-time analogue replaces PP by a generator QQ and the equation πP=π\pi P=\pi by πQ=0\pi Q = 0, leading to Continuous-Time Markov Chains and the Kolmogorov Forward and Backward Equations. When the chain satisfies the detailed balance condition πiPij=πjPji\pi_i P_{ij} = \pi_j P_{ji} it is reversible, connecting to Reversible Markov Chains and Detailed Balance and the electrical-network analogy.

Real-World Applications

🔬 Where this appears

Historical Development

⏳ History
- 1906 — Andrey Markov publishes the first paper on chains of dependent variables, proving a law of large numbers without independence.
- 1907 — Markov extends his results, establishing what we now call irreducibility and the role of the dominant eigenvalue.
- 1912–1913 — Markov analyses letter sequences in Pushkin's Eugene Onegin, the first empirical application.
- 1907–1912 — Georg Frobenius and Oskar Perron develop the spectral theory of nonnegative matrices (Perron–Frobenius theorem), later seen as the algebraic heart of stationary-distribution theory.
- 1931 — Andrey Kolmogorov lays measure-theoretic foundations for Markov processes and derives the forward/backward differential equations for the continuous-time case.
- 1936–1938 — Wolfgang Doeblin introduces coupling and the "Doeblin condition," giving a powerful route to convergence and ergodicity.
- 1953 — Metropolis, Rosenbluth, Rosenbluth, Teller and Teller publish the Metropolis algorithm, launching MCMC in computational physics.
- 1970 — W. K. Hastings generalises it to the Metropolis–Hastings algorithm, opening the door to Bayesian computation.
- 1996–1998 — Sergey Brin and Larry Page apply stationary distributions of the web graph to create PageRank, founding Google.

Subtleties & Limits

open-problem

For finite chains the theory is complete, but quantitative and infinite-state questions remain rich. Mixing-time estimation — how many steps until ∥μ(0)Pn−π∥TV<ε\|\mu^{(0)}P^n - \pi\|_{TV} < \varepsilon — is governed by the spectral gap, yet computing it sharply for high-dimensional chains (e.g. those used in MCMC for hard combinatorial measures) is often open and ties into complexity theory. The cutoff phenomenon, where convergence happens abruptly within a narrow window, is proven only for special families and its general characterisation is unresolved. For countably infinite chains, distinguishing positive recurrence, null recurrence, and transience requires delicate Lyapunov-function or Foster–Lyapunov criteria, and explicit stationary distributions may not exist in closed form. Non-reversible chains, which can mix faster than reversible ones, lack a comprehensive spectral theory — designing optimal non-reversible MCMC samplers is an active research frontier.

See Also

Perron–Frobenius Theorem · Random Walks on Graphs · Ergodic Theory · PageRank · Coupling of Stochastic Processes · Poisson Processes · Renewal Theory