Ergodicity and mixing: why your backtest can quietly lie
When you backtest a strategy on 20 years of data, you're implicitly assuming the market is ergodic β that one long path represents the full distribution. When ergodicity breaks, the backtest is meaningless. Mixing speed says how long the path needs to be for it to be safe.
When you backtest a strategy on 20 years of data and assume the result generalises, you are implicitly assuming the market is ergodic: one long historical path gives the same distribution as averaging across infinitely many parallel universes. When ergodicity breaks — regime changes, structural shifts, absorbing states — your backtest is a sample of one non-representative trajectory, and ‘on average’ becomes a meaningless phrase. Birkhoff’s ergodic theorem is the formal guarantee that the swap is legal, and mixing speed says how long the horizon needs to be before the guarantee kicks in.
β Intro Β· expand
Try first (productive failure)
Before the worked example: spend 60 seconds taking your best shot at this.
A guess is fine β being briefly wrong about a problem makes the explanation
land harder when you read it. This appears once per tutorial; skip
if you already know the trick.
60s
β Try first Β· expand
Worked example
A sticky 2-state Markov chain has transition matrix $P = \begin{pmatrix} 0.95 & 0.05 \\ 0.05 & 0.95 \end{pmatrix}$. (a) Confirm the chain is ergodic. (b) Compute the second eigenvalue $\lambda_2$. (c) Report the half-life of the total-variation distance from stationarity (how many steps to halve the distance).
β Worked example Β· expand
Practice 1 of 3Type a fraction, decimal, or expression β mathjs parses it.
β Practice Β· expand
Reflection
Slow mixing breaks the OLS independence assumption that justifies its standard errors. Why is this the formal motivation for Newey-West / HAC standard errors, and which Markov-chain quantity ($\lambda_2$, mixing time, autocorrelation length) is the right knob to scale them?