Markov Chains — Transition Matrices and Stationary Distributions
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 whose entries are conditional probabilities, and its long-run behaviour is captured by a stationary distribution satisfying . Applies to: queueing theory, PageRank, statistical physics, genetics, MCMC sampling. Core machinery developed by Andrey Markov (1906); convergence theory matured through the 20th century.
A discrete-time Markov chain on a finite or countable state space is a sequence of random variables in which the conditional distribution of given the entire past depends only on — the memoryless or Markov property. The one-step dynamics are summarised by a transition matrix with , a row-stochastic matrix. The central questions of the theory are: how does the distribution evolve (answer: by repeated matrix multiplication), and does it settle down to an equilibrium (answer: under irreducibility and aperiodicity, yes — to the unique stationary distribution ). The surprising fact is that the long-run fraction of time spent in a state equals regardless of the starting state, and equals the reciprocal of the mean return time. This single framework unifies random walks, gambling problems, web search, and the entire engine of modern Bayesian computation.
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 , and equilibrium is a left eigenvector of with eigenvalue . Probability theory becomes the spectral theory of a stochastic matrix.Formal Statement
Markov Chain and the Markov Property
Let be a countable set (the state space). A sequence of -valued random variables is a (time-homogeneous) Markov chain if for all and all states with positive probability,
Here is the transition probability from to , and is the transition matrix. The initial distribution is the row vector with .
Stochastic Matrix
A matrix is row-stochastic (or simply stochastic) if
Every transition matrix is stochastic, and conversely every stochastic matrix with a chosen initial distribution defines a Markov chain.
$n$-Step Transition Matrix and Distribution Evolution
Write for the -step transition probability. Then
where is the distribution at time .
Chapman–Kolmogorov Equations
For all and all states ,
Stationary Distribution
A probability row vector (so , ) is a stationary distribution (or invariant distribution) of if
If , then for all : the chain is in statistical equilibrium.
Irreducibility, Period, Recurrence
- The chain is irreducible if every state can be reached from every other: for all there exists with .
- The period of state is . The chain is aperiodic if for all (in an irreducible chain the period is a common value).
- A state is recurrent if , and positive recurrent if the mean return time is finite, where .
Existence, Uniqueness, and Convergence — the Fundamental Theorem
Let be the transition matrix of an irreducible Markov chain on .
- A stationary distribution exists iff the chain is positive recurrent; when it exists it is unique and satisfies for all .
- (Return-time formula) , the reciprocal of the mean return time to .
- (Convergence) If in addition the chain is aperiodic, then for every initial distribution ,
Why It Holds / Derivation
Existence of $\pi$ on a finite irreducible chain
We sketch the finite-state argument, the most important undergraduate case.
- Stochasticity gives eigenvalue 1. Since each row of sums to , the all-ones column vector satisfies . Thus is an eigenvalue of (a right eigenvector). A matrix and its transpose share eigenvalues, so there exists a left eigenvector with .
- Sign control via Perron–Frobenius. Irreducibility means (viewed as a nonnegative matrix) is irreducible in the matrix sense. The Perron–Frobenius theorem guarantees that the spectral radius equals , is a simple eigenvalue, and its left eigenvector can be taken with all entries strictly positive.
- Normalisation. Since and is finite (finite state space), set . Then is a probability vector with , establishing existence.
Uniqueness and the return-time formula
- Uniqueness. Perron–Frobenius makes eigenvalue simple, so its eigenspace is one-dimensional; the only probability vector in it is . Hence is unique.
- Return-time identity. Define the expected number of visits to between consecutive visits to a fixed reference state. The renewal-reward theorem says the long-run fraction of time in state equals (expected visits to per cycle)/(expected cycle length). Choosing the cycle to be a return to itself gives one visit per cycle of mean length , so the long-run frequency is . By the ergodic theorem for Markov chains this frequency equals . Hence , and finiteness of (positive recurrence) is exactly the condition for .
Convergence under aperiodicity (coupling sketch)
- Construct two coupled copies. Run a chain started from and an independent chain started from , evolving by the same .
- Coupling time. Irreducibility + aperiodicity guarantees the joint chain is irreducible on and reaches the diagonal with probability in finite expected time .
- Once coupled, stay coupled. After , run identically. Since for all ,
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
Think of a frog hopping among lily pads. The transition matrix 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 and let them all hop once, the new cloud is ; hop again, . The stationary distribution is the special cloud shape that hops to itself — pour the frogs out in proportion 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 — the system forgets its initial condition. And has a beautifully concrete meaning: the busiest pads (high ) are exactly the ones the frog returns to fastest.
Two-state Markov chain and its convergence to the stationary distribution
<svg viewBox="0 0 640 360" xmlns="http://www.w3.org/2000/svg">
<rect width="640" height="360" fill="#0a0e17"/>
<text x="20" y="30" fill="#e2e8f0" font-family="sans-serif" font-size="16">Two-state chain: P=[[0.7,0.3],[0.4,0.6]]</text>
<!-- states -->
<circle cx="160" cy="120" r="34" fill="none" stroke="#94a3b8" stroke-width="2"/>
<text x="150" y="126" fill="#e2e8f0" font-family="sans-serif" font-size="20">A</text>
<circle cx="360" cy="120" r="34" fill="none" stroke="#94a3b8" stroke-width="2"/>
<text x="350" y="126" fill="#e2e8f0" font-family="sans-serif" font-size="20">B</text>
<!-- A to B -->
<path d="M194 108 Q260 80 326 108" fill="none" stroke="#94a3b8" stroke-width="2" marker-end="url(#ar)"/>
<text x="250" y="78" fill="#e2e8f0" font-family="sans-serif" font-size="13">0.3</text>
<!-- B to A -->
<path d="M326 132 Q260 160 194 132" fill="none" stroke="#94a3b8" stroke-width="2" marker-end="url(#ar)"/>
<text x="250" y="168" fill="#e2e8f0" font-family="sans-serif" font-size="13">0.4</text>
<!-- self loops -->
<path d="M132 100 Q100 60 150 88" fill="none" stroke="#94a3b8" stroke-width="2" marker-end="url(#ar)"/>
<text x="92" y="70" fill="#e2e8f0" font-family="sans-serif" font-size="13">0.7</text>
<path d="M388 100 Q420 60 370 88" fill="none" stroke="#94a3b8" stroke-width="2" marker-end="url(#ar)"/>
<text x="418" y="70" fill="#e2e8f0" font-family="sans-serif" font-size="13">0.6</text>
<!-- convergence plot -->
<line x1="120" y1="320" x2="560" y2="320" stroke="#94a3b8" stroke-width="1.5"/>
<line x1="120" y1="320" x2="120" y2="210" stroke="#94a3b8" stroke-width="1.5"/>
<text x="540" y="338" fill="#94a3b8" font-family="sans-serif" font-size="12">n</text>
<text x="70" y="216" fill="#94a3b8" font-family="sans-serif" font-size="12">P(A)</text>
<!-- stationary line pi_A = 4/7 ~ 0.571 -->
<line x1="120" y1="272" x2="560" y2="272" stroke="#94a3b8" stroke-width="1" stroke-dasharray="5 4"/>
<text x="565" y="276" fill="#94a3b8" font-family="sans-serif" font-size="11">π₀=0.571</text>
<!-- curve from P(A)=1 converging -->
<path d="M120 213 L175 245 L230 262 L285 268 L340 271 L395 272 L450 272 L560 272" fill="none" stroke="#d4a853" stroke-width="2.5"/>
<text x="180" y="232" fill="#d4a853" font-family="sans-serif" font-size="12">start X₀=A</text>
<defs>
<marker id="ar" markerWidth="8" markerHeight="8" refX="6" refY="3" orient="auto">
<path d="M0,0 L6,3 L0,6 Z" fill="#94a3b8"/>
</marker>
</defs>
</svg>
Worked Examples
Two-state chain — solving $\pi P = \pi$
Given: with- Write and solve :
- The first equation gives . (The two equations are dependent — expected, since rows of are linearly dependent.)
- Apply normalisation : , so .
- Check via return time: steps mean return time to .
Weather chain — long-run fractions and a finite-step forecast
Given: States with- Two-step forecast: . Then
- Stationary distribution: solve , giving , so . Normalise: , , .
- Interpretation: in the long run roughly of days are sunny, independent of today's weather (chain is irreducible and aperiodic — note kills periodicity).
- Mean return time to Rain: days.
Common Misconceptions
A stationary distribution is not a fixed state. The chain does not stop at . Individual trajectories keep jumping forever; it is the probability distribution over states that is frozen. Likewise, "" is a statement about the row vector (a left eigenvector), not about (the right eigenvector , which every stochastic matrix has trivially). Confusing left and right eigenvectors is the single most common error. Existence of does not guarantee convergence. A unique stationary distribution can exist while 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) always converges to for irreducible positive-recurrent chains, but the instantaneous distribution may oscillate forever.A periodic chain with no convergence
Take and the deterministic swap
Non-uniqueness when reducibility fails
Take with two absorbing states and one transient:
Connections
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 by a generator and the equation by , leading to Continuous-Time Markov Chains and the Kolmogorov Forward and Backward Equations. When the chain satisfies the detailed balance condition it is reversible, connecting to Reversible Markov Chains and Detailed Balance and the electrical-network analogy.
Real-World Applications
- Google PageRank. The web is a Markov chain whose states are pages and transitions are hyperlinks (plus a "teleport" term ensuring irreducibility/aperiodicity). The stationary distribution is the PageRank vector — pages with high are visited often by a random surfer and ranked higher.
- Markov Chain Monte Carlo (MCMC). Algorithms like Metropolis–Hastings and the Gibbs sampler construct a chain whose stationary distribution is a desired (often intractable) target ; running it long enough produces samples from . This is the backbone of Bayesian statistics and statistical physics simulation.
- Queueing theory. The number of customers in an M/M/1 queue is a birth–death Markov chain; its stationary distribution gives steady-state queue length, waiting time, and server utilisation .
- Population genetics. The Wright–Fisher and Moran models treat allele frequencies as Markov chains; absorption probabilities give fixation probabilities of genes.
- Speech and language. Hidden Markov Models underlie speech recognition, part-of-speech tagging, and bioinformatics gene-finding; Markov's own vowel/consonant study was the prototype.
- Reliability engineering. Systems cycling through "working/degraded/failed" states are modelled as Markov chains; yields long-run availability.
- Card shuffling. The riffle shuffle is a Markov chain on the symmetric group; the "seven shuffles" result of Bayer–Diaconis is a cutoff-phenomenon statement about its convergence to the uniform stationary distribution.
Historical Development
- 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
For finite chains the theory is complete, but quantitative and infinite-state questions remain rich. Mixing-time estimation — how many steps until — 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.