Markov Chains
Memoryless stochastic processes governed by a transition matrix, the stationary distribution as a left eigenvector, the ergodic theorem that makes long-run averages predictable, and hitting-time systems that price first-passage problems.
Prerequisites: Random Variables & Distributions, Linear Algebra for Quants
A Markov chain is a stochastic process with no memory: the future depends on the past only through the present state. That single simplifying assumption is strong enough to model regime switching, credit-rating migration, order-book dynamics, and the random walks underlying option pricing, yet weak enough to remain analytically tractable, because the entire dynamics collapse into a matrix. Understanding chains means understanding how a matrix's spectrum governs the long-run behaviour of a random system, which is why this topic sits at the meeting point of probability and Linear Algebra for Quants.
The Markov property and the transition matrix
A discrete-time process on a finite (or countable) state space is a Markov chain if Conditioning on the whole history is the same as conditioning on the current state alone. The numbers form the transition matrix , a row-stochastic matrix: and each row sums to (from some state you go somewhere with probability 1). Represent a distribution over states as a row vector ; then one step evolves it by right-multiplication, , and steps by The Chapman–Kolmogorov equation is just matrix multiplication, and it is the reason the entire theory is linear-algebraic: multi-step probabilities are matrix powers.
The stationary distribution
A distribution is stationary if it is unchanged by a step: Read as an Eigenvalues & Eigenvectors equation, is a left eigenvector of with eigenvalue . Every stochastic matrix has as an eigenvalue (the all-ones vector is a right eigenvector since rows sum to 1), and the Perron–Frobenius theorem guarantees a corresponding non-negative left eigenvector that, normalised, is a genuine probability distribution. The stationary distribution is the long-run fraction of time spent in each state and the equilibrium the chain relaxes toward.
Classification, ergodicity, and convergence
Whether is unique and whether the chain converges to it depend on structural properties:
- Irreducible: every state reaches every other state (the chain is one communicating class). This gives a unique stationary distribution.
- Aperiodic: the chain is not trapped in deterministic cycles (gcd of return times is 1). This ensures actually converges rather than oscillating.
- Positive recurrent: expected return time to each state is finite (automatic for finite irreducible chains).
An irreducible, aperiodic, positive-recurrent chain is ergodic, and then the fundamental convergence theorem holds: The chain forgets its start. The ergodic theorem upgrades this to time averages: for any function , This is the The Law of Large Numbers for dependent data, a single long trajectory estimates equilibrium expectations, which is exactly what makes Markov Chain Monte Carlo work: engineer a chain whose stationary distribution is your target, run it long, and average. The rate of convergence to is governed by the second-largest eigenvalue modulus (the spectral gap ): mixing time scales like , so the spectrum literally sets how fast the chain equilibrates.
Worked example, a two-state regime model
Model markets as "calm" (state 1) and "stressed" (state 2), with Calm persists (95%), stress mean-reverts (70% chance of exiting). Solve with . The balance equation is (flow out of calm equals flow in), giving , so The market is stressed about 14% of the time in the long run. The expected duration of a stress spell is periods (a geometric first-passage result). This tiny model is the skeleton of regime-switching volatility models and Regime Detection; the same eigenvector calculation scales to credit-migration matrices with dozens of rating states.
Hitting times and first passage
Many quant questions, time to default, gambler's ruin, barrier options, are hitting-time problems. Let be the expected number of steps to reach a target set starting from state . Conditioning on the first step gives a linear system: Similarly, absorption probabilities solve the harmonic system with boundary values on , on . Gambler's ruin is the canonical instance: a symmetric walk on with absorbing ends gives ruin probability , linear in wealth, and expected duration . These first-step decompositions are the discrete cousins of the PDEs that price barrier and American options, and the harmonic-function structure links directly to Martingales.
Failure modes and subtleties
- The Markov property is an assumption, often false. Real returns have longer memory (volatility clustering, momentum); forcing a first-order chain loses it. Remedy: enlarge the state to include recent history (a -th order chain is Markov on tuples), at the cost of exponentially more states.
- Reducible or periodic chains don't converge to a unique . Multiple communicating classes give multiple stationary distributions; periodicity makes oscillate forever. Check irreducibility and aperiodicity before trusting equilibrium.
- Slow mixing hides in a small spectral gap. A chain can be ergodic in theory but take astronomically long to mix if (near-decomposable, "sticky" states). MCMC that hasn't mixed gives confidently biased estimates.
- Non-stationary transition matrices. Estimated from data assumes the dynamics are time-homogeneous; regime parameters drift, so a migration matrix fit in calm markets misprices stress.
- Continuous-time subtlety. The continuous analogue uses a generator matrix (rows sum to ) with ; discretising a continuous chain naively can produce invalid transition matrices.
In interviews
Stationary-distribution questions are staples: set up and solve for a small chain, and recognise it as a left-eigenvector problem. Gambler's ruin is asked constantly, know both the ruin probability ( symmetric, and the geometric-ratio formula for biased walks) and the expected duration. Expect first-step-analysis prompts ("expected number of coin flips to see HH vs. HT") which are hitting-time systems in disguise and famously have different answers. A deeper probe is "when is the stationary distribution unique?", irreducibility, and "what controls how fast the chain reaches it?", the spectral gap, tying back to Eigenvalues & Eigenvectors. Strong candidates connect the ergodic theorem to why MCMC and long-run backtest averages are meaningful for dependent data.
Practice in interviews
Further reading
- Norris, Markov Chains
- Levin, Peres & Wilmer, Markov Chains and Mixing Times
- Grimmett & Stirzaker, Probability and Random Processes