Probability and statistics
Stochastic processes and Markov chains
Sequences of random states evolving over time, where Markov chains depend only on the current state.
IntuitionIf tomorrow only cares about today, how far can you predict the future?
Picture a frog hopping between lily pads on a pond, or a board-game piece moving square by square, or tomorrow's weather switching between sunny and rainy. In each case there is a state (which pad, which square, which weather) that changes at each tick of a clock, and the change is not fixed in advance — it is random. A stochastic process is simply a family of random variables indexed by time , one random state for every moment. The frog's hop, and a huge number of real systems — gene mutations, customers arriving at a queue, prices ticking on an exchange, a web surfer clicking links — are all stochastic processes in this sense. A Markov chain is the special, enormously useful case where the frog is forgetful: the probability of the next hop depends only on the lily pad it is currently sitting on, never on the winding path that got it there.
UndergraduateThe Markov property, transition matrices, and stationary distributions
Definition: Markov chain
Let be a countable set of states and let for be a stochastic process taking values in . The process is a Markov chain if it has the Markov property: for every choice of states and every . In words, the whole past gives no extra information about once is known — the present state is a sufficient summary of the entire history.
When the state space is finite (or countable) and the chain is time-homogeneous, all this randomness is captured by a single transition matrix with entries — the probability of jumping to state given the chain is currently at . Because from any state the chain must go somewhere, every row of is a probability distribution: it is non-negative and sums to one, . A matrix with this row-sum-one property is called row-stochastic. Multiplying -step and -step transitions composes exactly as matrix multiplication, the Chapman–Kolmogorov equation , so the probability of being in each state after steps starting from a distribution is simply .
A probability distribution on is stationary if it is a fixed point of this dynamics: together with and . Once the chain's distribution equals at one time step, it equals at every later time step — the population of frogs on each pad stops changing in aggregate, even though each individual frog keeps hopping randomly. Finding reduces to solving a linear system, which is exactly what the fundamental theorem below turns into a guarantee of existence, uniqueness, and convergence.
| Property | Definition | Consequence |
|---|---|---|
| Irreducible | Every state can reach every other state with positive probability | The chain has (at most) one stationary distribution |
| Aperiodic | The greatest common divisor of possible return times to a state is 1 | Powers converge entrywise, not just on average |
| Recurrent | Starting from state , the chain returns to with probability 1 | On a finite irreducible chain this always holds automatically |
If a Markov chain on a finite state space is irreducible and aperiodic, then there exists a unique stationary distribution with , for every state, and — every row of converges to as , regardless of the starting distribution.
Why is it true?
This is the reason Markov chains are useful at all: it says the long-run behavior of a randomly evolving system settles into a single predictable pattern that forgets its starting point, and it tells us exactly what that pattern is (the unique fixed point of the transition dynamics).
Proof
Existence and uniqueness. Since is row-stochastic, the all-ones vector is a right eigenvector with eigenvalue 1, so 1 is also an eigenvalue of (a matrix and its transpose share eigenvalues), and there is a corresponding left eigenvector with . Irreducibility means is the transition matrix of a strongly connected graph, so the Perron–Frobenius theorem applies: the eigenvalue 1 is simple (multiplicity one) and its eigenvector can be chosen strictly positive, giving uniqueness after normalizing so entries sum to 1.
Convergence. Aperiodicity plus irreducibility means all other eigenvalues of satisfy (this is the part periodicity would break: a periodic chain has extra eigenvalues exactly on the unit circle, such as , which never die out). Writing an arbitrary starting distribution in the eigenbasis of , the component along (eigenvalue 1) survives unchanged forever, while every other component is multiplied by at step and shrinks geometrically to zero.
Combining the two steps, converges to the eigenvalue-1 component alone, which is exactly , and since this holds for every starting distribution (including each point mass, i.e. each row of the identity), every row of converges to as claimed.
Let be the all-ones matrix ( = number of web pages) and let be the row-stochastic link matrix (page links equally to each page it points to; pages with no outlink are sent uniformly to all pages). For any damping factor , the Google matrix is the transition matrix of an irreducible, aperiodic Markov chain, so by the fundamental theorem above it has a unique stationary distribution with — this is exactly the PageRank vector, and the power-iteration algorithm converges to it from any starting guess.
Why is it true?
This turns the vague idea "important pages are linked to by other important pages" into a well-posed fixed-point problem with a guaranteed unique solution, and it explains why simply repeating "spread rank along links" (power iteration) is guaranteed to work rather than oscillate or diverge.
Proof
Irreducibility. Because , every entry of is strictly positive (), so from any page there is a positive-probability direct jump to any other page in one step — the underlying graph is trivially strongly connected, hence is irreducible.
Aperiodicity. A chain where every state can go directly to every state (including itself, since too) has return times of every length available, whose greatest common divisor is 1; so is aperiodic.
Existence, uniqueness, convergence. is row-stochastic by construction (a convex combination of two row-stochastic matrices and is row-stochastic), and it is irreducible and aperiodic as just shown, so the fundamental theorem of finite Markov chains applies directly: a unique stationary exists with , and converges entrywise to a matrix with every row equal to .
Power iteration. Since for any starting distribution , and every row of converges to as , the weighted average converges to as well — this is precisely why repeatedly applying from an arbitrary starting rank (commonly the uniform distribution) converges to the true PageRank vector.
UndergraduateReal-World Applications and Worked Examples
Markov chains model an enormous range of systems where "forgetting the past given the present" is a reasonable approximation. Google's original PageRank algorithm ranks web pages by the stationary distribution of a random surfer who clicks links (proved above). In biology, DNA sequences and protein folding pathways are modeled as Markov chains over nucleotides or conformations. In finance and operations research, queueing systems (customers waiting at a checkout) and inventory levels are tracked as Markov chains to compute long-run waiting times and stock-out probabilities. In speech recognition and natural-language processing, hidden Markov models chain together phonemes or part-of-speech tags. And in computer science, MCMC (Markov chain Monte Carlo) algorithms build a Markov chain whose stationary distribution is a hard-to-sample target distribution, then simulate it to draw approximate samples.
Example: Stationary weather distribution
A simplified weather model has two states, Sunny and Rainy, with transition matrix (row 1 = from Sunny, row 2 = from Rainy; so from Sunny it stays Sunny with probability and becomes Rainy with probability ). Find the stationary distribution .
Solution
The stationary equations are , i.e. and , together with .
The first equation simplifies to , i.e. (the second equation gives the same relation, as it must since the rows of are dependent).
Substituting into the normalization: , so and , .
So — in the long run this weather chain is Sunny of the time. This matches intuition: state 1 (Sunny) is much "stickier" (probability of staying) than state 2 (Rainy, probability of staying), so the chain spends most of its time in the sticky state.
Example: PageRank of a three-page web
A tiny web has three pages : page links equally to and , page links only to , and page links only back to : . Model a random surfer's clicks as a Markov chain on and find the PageRank vector .
Solution
First check the chain is irreducible and aperiodic: every page can reach every other page (via ), and there are cycles of length 2 () and length 3 (), whose gcd is 1, so the fundamental theorem guarantees a unique stationary .
Write the balance equations column by column: only receives flow from , only from , and from both and : .
The first two equations give and directly; substituting into the normalization gives , i.e. .
Solving, , hence . Page and page tie for the highest rank because each receives a link from a page that itself only has one outlink to send all its weight through — exactly the kind of "vote concentration" PageRank is designed to reward.
The Markov property says that, given the present state , the next state is:
A 3-state chain has transition matrix rows that must each:
For the transition matrix , which vector satisfies and ?
In Google's original PageRank, the damping factor (mixing in a uniform jump to every page) is essential mainly because it guarantees the Google matrix is:
References
- David A. Levin, Yuval Peres, Elizabeth L. Wilmer (2017). Markov Chains and Mixing Times
- Sergey Brin, Lawrence Page (1998). The Anatomy of a Large-Scale Hypertextual Web Search Engine
- James R. Norris (1997). Markov Chains