Quant Memo
Core

The Bias-Variance Decomposition

A model's average squared error splits cleanly into three separate pieces — being systematically wrong, being erratically wrong, and noise nothing can fix — and the decomposition explains why a worse-looking model can beat a better-looking one out of sample.

Prerequisites: Training Error vs Generalization Error, Bias, Variance, and the Quality of Estimators

Two models can post the same disappointing test error for completely different reasons, and knowing which reason applies changes what you should do next. One model might be making the same mistake every time — consistently underestimating a stock's fair value, say — which more data will never fix, because the pattern in the data was never rich enough for the model to capture. The other might be making a different mistake every time it is retrained, wildly over- and under-shooting depending on which historical days happened to land in the training set, which is a problem more data or a simpler model can genuinely fix. The bias-variance decomposition is the formula that tells these two failure modes apart.

The analogy: two ways to miss the bullseye

Imagine two archers, each shooting five arrows at a target. The first archer's arrows land in a tight cluster, but the cluster is a foot to the left of the bullseye — every shot is consistent, and every shot is wrong in the same way. That archer is biased: fixing it means changing their aim, not their steadiness. The second archer's arrows scatter widely around the bullseye — some land dead center, some land a foot away in every direction — but if you averaged all five arrows' positions, that average would sit right on the bullseye. That archer is not biased; they are high variance: fixing it means steadying their hand, not changing their aim.

A model trained repeatedly on different samples of the same market is exactly this archer. Each retraining is one arrow. If every retrained version makes the same systematic error, that is bias. If different retrained versions swing wildly in different directions, that is variance. Total error is driven by both, and reducing one does not automatically reduce the other — a steadier archer aiming at the wrong spot still misses.

The formula

For a prediction target yy with true underlying function f(x)f(x) plus unavoidable noise ε\varepsilon (so y=f(x)+εy = f(x) + \varepsilon), and a model f^(x)\hat f(x) trained on one particular random sample of data, the expected squared error at a point xx, averaged over every possible training sample the model could have been handed, decomposes as

E[(yf^(x))2]=(E[f^(x)]f(x))2bias2+E[(f^(x)E[f^(x)])2]variance+σ2irreducible noise\mathbb{E}\big[(y - \hat f(x))^2\big] = \underbrace{\big(\mathbb{E}[\hat f(x)] - f(x)\big)^2}_{\text{bias}^2} + \underbrace{\mathbb{E}\big[(\hat f(x) - \mathbb{E}[\hat f(x)])^2\big]}_{\text{variance}} + \underbrace{\sigma^2}_{\text{irreducible noise}}

In words, reading each term separately: bias is how far the average prediction, across every possible training sample you could have drawn, sits from the true value — the archer's average arrow position minus the bullseye. Variance is how much any single prediction typically swings around that average — how scattered the arrows are around their own cluster center, regardless of where that center is. Irreducible noise is randomness baked into the target itself — the wind gusting during every shot — which no model, however good, can remove. The three terms add up to the total expected squared error, and improving one does not automatically improve the others.

Worked example 1: two models, same target, different failure

The true value at some point is f(x)=5.0f(x) = 5.0. Two models are each retrained five times on five different resampled datasets, and each retrained version's prediction at xx is recorded.

Model A (a simple, heavily smoothed model) predicts: 4.0, 4.1, 3.9, 4.0, 4.0.

mean=4.0+4.1+3.9+4.0+4.05=4.00,bias=4.005.00=1.00,bias2=1.00\text{mean} = \frac{4.0+4.1+3.9+4.0+4.0}{5} = 4.00, \qquad \text{bias} = 4.00 - 5.00 = -1.00, \qquad \text{bias}^2 = 1.00 variance=02+0.12+(0.1)2+02+025=0.025=0.004\text{variance} = \frac{0^2 + 0.1^2 + (-0.1)^2 + 0^2 + 0^2}{5} = \frac{0.02}{5} = 0.004

Model B (a flexible, lightly regularized model) predicts: 5.5, 3.0, 6.2, 4.0, 6.3.

mean=5.5+3.0+6.2+4.0+6.35=5.00,bias=5.005.00=0\text{mean} = \frac{5.5+3.0+6.2+4.0+6.3}{5} = 5.00, \qquad \text{bias} = 5.00 - 5.00 = 0 variance=0.52+(2.0)2+1.22+(1.0)2+1.325=0.25+4.00+1.44+1.00+1.695=8.385=1.676\text{variance} = \frac{0.5^2 + (-2.0)^2 + 1.2^2 + (-1.0)^2 + 1.3^2}{5} = \frac{0.25+4.00+1.44+1.00+1.69}{5} = \frac{8.38}{5} = 1.676

With irreducible noise σ2=0.05\sigma^2 = 0.05 for both, total expected squared error is 1.00+0.004+0.05=1.0541.00 + 0.004 + 0.05 = 1.054 for Model A versus 0+1.676+0.05=1.7260 + 1.676 + 0.05 = 1.726 for Model B. Model B is unbiased on average and Model A is badly biased, yet Model A wins decisively, because its variance is negligible while Model B's is enormous. Being right on average across many retrainings is worthless if any single retraining is wildly unpredictable — you only ever get to deploy one trained model, not the average of infinitely many.

Worked example 2: why averaging fixes variance but not bias

Model B's variance of 1.676 came from a single trained model. Suppose instead two independently retrained copies of Model B are averaged together at prediction time. For independent estimators, the variance of an average of mm copies is the single-copy variance divided by mm:

Var(f^1(x)+f^2(x)2)=Var(f^(x))2=1.6762=0.838\text{Var}\left(\frac{\hat f_1(x) + \hat f_2(x)}{2}\right) = \frac{\text{Var}(\hat f(x))}{2} = \frac{1.676}{2} = 0.838

Averaging two copies cut variance from 1.676 to 0.838 — nearly in half, exactly as the formula predicts — without touching the bias, which was already zero and stays zero, because averaging unbiased things is still unbiased. This is precisely the mechanism behind ensembling: it attacks variance, not bias, which is why an ensemble of independently biased models (all consistently wrong the same way) does not help nearly as much as an ensemble of independently high-variance ones.

Bias–variance explorer
model complexity →sweet spot
test error 1.54train error 0.92underfitting

Drag the complexity slider above and watch the two curves. Low complexity is the left side of the plot — high bias, near-zero variance, like Model A. High complexity is the right side — near-zero bias, high variance, like Model B. The total error curve (their sum, plus the irreducible floor) dips somewhere in the middle, which is exactly what the two worked examples above computed by hand at two single points on that curve.

low bias, low variance high bias, low variance low bias, high variance high bias, high variance
Bias is where the cluster is centered relative to the bullseye; variance is how spread out the cluster is, regardless of where its center sits. The two are independent dimensions of "wrong."

Total error is bias-squared plus variance plus a noise floor you cannot remove. A model that looks worse by one measure can win overall if it is far better on the other — never judge a model by average accuracy alone without asking whether its errors are consistent or erratic.

What this means in practice

Simple, heavily regularized models (a linear regression on a handful of macro factors) sit on the high-bias, low-variance side: retrain them on a different five-year window and the coefficients barely move, but they may never capture a real nonlinear effect that is genuinely there. Flexible models (a deep gradient-boosted tree on thousands of features) sit on the low-bias, high-variance side: they can capture real nonlinear structure, but retrain on a slightly different window and the predictions can shift substantially. The right choice depends on how much data you actually have relative to how complex the true relationship is — more data shrinks variance for a fixed model, which is why the same flexible model that overfits on two years of daily data can generalize fine on twenty.

Practice

  1. A model retrained on ten different bootstrap samples produces predictions at a fixed point that are all within 0.01 of each other but consistently 2.0 away from the true value. Which term in the decomposition dominates its error?
  2. Averaging four independent copies of a model with variance 0.80 and zero bias — what is the resulting variance, and what is the resulting bias?
  3. Why can't irreducible noise be reduced by using a better model, more data, or more regularization?

The trap is assuming a model with a lower training error must have lower bias, or that ensembling always helps. Averaging reduces variance, not bias — bagging ten copies of a systematically wrong model just produces a systematically wrong average, faster and with more confidence. And the decomposition is defined over repeated retraining on different samples, a thought experiment, not something you can compute from a single trained model's residuals alone; a single model's low residual error on its own training data tells you almost nothing about which term dominates its true bias-variance trade-off.

Related concepts

Practice in interviews

Further reading

  • Hastie, Tibshirani & Friedman, The Elements of Statistical Learning, ch. 7.3
  • Geman, Bienenstock & Doursat, Neural Networks and the Bias/Variance Dilemma (1992)
ShareTwitterLinkedIn