Quant Memo
Advanced

Mixing Times and Convergence to Stationarity

How long a Markov chain takes to 'forget' where it started and start behaving like a random draw from its long-run distribution — the number that tells you whether a simulation's early steps should be thrown away, and how many.

Prerequisites: Markov Chains

You build a Markov chain model of a stock's regime (bull, bear, choppy) and want to simulate 10,000 draws from its long-run regime distribution to feed a Monte Carlo backtest. You start the simulation in the "bull" state (today's actual regime) and run it forward. But the first several hundred simulated steps aren't really draws from the long-run distribution — they're still colored by the fact that you deliberately started in "bull." Using those early steps as if representative subtly biases the simulation toward the starting state. Mixing time is the number of steps a chain needs before its distribution over states gets close enough to its true stationary distribution that starting-point memory has effectively faded — the number telling you how much of a simulation to discard before trusting it.

An analogy: a shuffled deck forgetting its starting order

A brand-new deck is perfectly ordered by suit and rank. After one riffle shuffle, it's still noticeably closer to the original order than to a truly random arrangement — an expert could still exploit leftover structure. After about seven riffle shuffles, mathematically, the deck is close enough to uniformly random that no practical test can tell it apart from a truly random deck. "Seven shuffles" is the deck's mixing time: not the point it becomes exactly random (that takes infinitely many shuffles), but the point it's random enough that starting order no longer detectably influences anything you'd care about.

The formulas, one piece at a time

Let π\pi be a Markov chain's stationary distribution — the long-run probability of being in each state, unchanging once reached. Let Pt(x,)P^t(x, \cdot) be the distribution over states after tt steps, starting from state xx. The total variation distance between two distributions measures how far apart they are:

dTV(Pt(x,),π)=12yPt(x,y)π(y).d_{TV}\big(P^t(x, \cdot), \pi\big) = \frac{1}{2} \sum_{y} \big| P^t(x, y) - \pi(y) \big|.

In plain English: this sums up, across every state yy, how much more (or less) likely the chain is to be in state yy after tt steps compared to its true long-run frequency, and halves the total to keep the distance between 0 (identical) and 1 (completely different). The mixing time tmix(ϵ)t_{\text{mix}}(\epsilon) is the smallest tt such that this distance drops below a small threshold ϵ\epsilon (commonly ϵ=0.25\epsilon = 0.25 or 1/41/4) for the worst-case starting state xx. In plain English: it's how many steps you need to run the chain before its current-state distribution is within a small, agreed-upon tolerance of the true long-run distribution, no matter where you started.

Worked example 1: a two-state regime chain

Consider a simple two-state regime chain: bull today stays bull with probability 0.9, switches to bear with probability 0.1; bear stays bear with probability 0.8, switches to bull with probability 0.2. Solving πP=π\pi P = \pi gives the stationary distribution πbull=0.2/(0.2+0.1)0.667\pi_{\text{bull}} = 0.2/(0.2+0.1) \approx 0.667, πbear0.333\pi_{\text{bear}} \approx 0.333. Starting deterministically in "bull" (P0=(1,0)P^0 = (1, 0)), after one step the distribution is (0.9,0.1)(0.9, 0.1) — total variation distance from π\pi is 12(0.90.667+0.10.333)=12(0.233+0.233)=0.233\frac{1}{2}(|0.9-0.667| + |0.1-0.333|) = \frac{1}{2}(0.233+0.233) = 0.233. After a few more steps this distance keeps shrinking geometrically (roughly by a factor related to the chain's second-largest eigenvalue, here about 0.7 per step), reaching below 0.050.05 by around step 8–9 — meaning after about 9 simulated steps, the "started in bull" bias has become negligible for practical purposes.

Worked example 2: why burn-in length matters for the backtest

Suppose you run 10,000 simulated regime paths, each starting from today's actual "bull" state, and want the long-run regime frequencies in your Monte Carlo sample to match the true π=(0.667,0.333)\pi = (0.667, 0.333). If you use all 10,000 steps of every path including the first 9, you're injecting extra "bull" weight from the biased early steps — a small effect per path, but if paths are short (say, only 20 steps total), those first 9 biased steps are nearly half the sample, materially skewing the regime frequencies toward bull relative to the true stationary mix. The standard fix, called "burn-in," discards the first tmixt_{\text{mix}} steps of each simulated path (here, roughly the first 9) before recording any statistics, ensuring what's kept is a fair sample of π\pi rather than a sample still colored by the deliberately chosen bull starting point.

simulated step bull (forced start) irregular bull/bear pattern past t_mix
A path forced to start in "bull" spends its early steps still shaped by that choice; past the mixing time it settles into the irregular bull/bear switching pattern that a fair draw from the stationary distribution would actually produce.
step t mixing threshold ε=0.05 t_mix ≈ 9
Total variation distance from the stationary distribution decays geometrically with each step; mixing time is where the curve first drops below the chosen tolerance, marking how much "burn-in" a simulation needs before it's discarded.

What this means in practice

Mixing time governs the burn-in period in any Markov-chain Monte Carlo (MCMC) simulation, regime-switching model simulation, or Markov chain-based scenario generator: too little burn-in leaves starting-point bias in your results, while excessive burn-in just wastes computation. Chains that mix slowly (near-absorbing states, or states that rarely communicate) need much longer burn-in and are also a red flag that the chain's long-run behavior may be poorly identified from short historical data in the first place.

Mixing time is how many steps a Markov chain needs before its distribution over states gets close (in total variation distance) to its stationary distribution, regardless of starting state; it's the number that tells you how many simulated steps to discard as "burn-in" before trusting the sample as representative of long-run behavior.

The classic mistake is running a Markov-chain simulation from a fixed, meaningful starting state (like "today's actual regime") and using the early simulated steps as if they already represented the unconditional long-run distribution. Especially with short simulated paths or slowly mixing chains, this silently biases results toward the starting state; always estimate the mixing time (or use a generous, checked burn-in) before treating simulated output as a fair sample of the stationary distribution.

Related concepts

Practice in interviews

Further reading

  • Levin & Peres, Markov Chains and Mixing Times, ch. 4
  • Ross, Introduction to Probability Models, ch. 4
ShareTwitterLinkedIn