On this page
Fit a straight line to wavy data and it misses the wave. Fit a degree-9 polynomial and it chases every bump of noise. The bias–variance tradeoff accounts for both failures exactly, and explains why the lowest training error rarely means the best predictions.
What is the bias–variance tradeoff?
Stuart Geman, Elie Bienenstock and René Doursat set out the idea for neural networks in their 1992 Neural Computation paper Neural Networks and the Bias/Variance Dilemma. Data come from y = f(x) + ε, where ε is noise with mean 0 and variance σ². You fit a model f̂ to one random training set, so f̂ is random too.
At any point x, the expected squared error against a fresh y splits into three parts:
E[(y − f̂(x))²] = (E[f̂(x)] − f(x))² + E[(f̂(x) − E[f̂(x)])²] + σ²
Bias² is how far the average fit, over all possible training sets, sits from the truth.
Variance is how much one fit wobbles around that average between training sets.
Noise is σ², the part no model can remove.
How do you derive the bias–variance decomposition?
Write m = E[f̂(x)]. Then y − f̂ = (f − m) + (m − f̂) + ε. Square and take expectations. What survives is (f − m)² + E[(m − f̂)²] + σ², which is bias² + variance + noise. It is the same split-around-the-mean step behind the law of total variance, worked out.
If expectation and variance feel shaky, the Fermi Concept Library covers every concept in mathematics and computing, so you can rebuild those first.
Worked example: degree 1, 3 and 9 fits to sin x
Here is the dilemma from the Geman, Bienenstock and Doursat paper in numbers we work out ourselves. Take 15 evenly spaced points on [0, 2π], ends included, set y = sin x + noise with σ = 0.3 (so σ² = 0.09), and fit by least squares.
Bias² is what the best polynomial of that degree still misses, averaged over the 15 points: about 0.243 for a straight line, 0.006 for degree 3 and practically zero for degree 9.
For least squares with p coefficients and n points, the variance averaged over the training x-values is exactly σ²p/n, because the trace of the hat matrix equals p. Here that is 0.006 per coefficient.
Adding bias², variance and noise:
Degree 1: 0.243 + 0.012 + 0.09 ≈ 0.345. It underfits: a line cannot bend.
Degree 3: 0.006 + 0.024 + 0.09 ≈ 0.12. The best of the three.
Degree 9: 0 + 0.060 + 0.09 ≈ 0.15. It overfits, with ten coefficients for fifteen points.
Training error tells the opposite story. Its expected value is bias² + σ²(1 − p/n), so the degree-9 fit scores about 0.03 on its own points, below the noise itself. A fit that beats the noise on training data has memorised noise. At degree 14 the curve passes through all 15 points, with zero training error and wild swings between them, a cousin of Runge's phenomenon, where more points make a polynomial worse.
Why do simple models underfit and complex models overfit?
A simple model has few knobs, so different training sets give nearly the same fit: low variance. The same rigidity stops it bending towards the truth: high bias. A complex model bends to anything, including the noise, so each training set gives a different curve.
In least squares, adding a coefficient never raises bias and always adds σ²/n of variance. Extra flexibility pays only while it removes more bias than it adds variance. For sin x with this noise, going from degree 3 to degree 5 adds two coefficients, 0.012 of variance, to remove the last 0.006 of bias, so degree 3 is where flexibility stops paying.
How does more data change the bias–variance tradeoff?
Variance σ²p/n shrinks as n grows, while bias barely changes. With 100 points the same sums give about 0.098 for degree 3 and 0.099 for degree 9, nearly a tie. At 200 points degree 9 edges ahead, about 0.0945 against 0.096. More data cannot rescue a rigid model, but it makes a flexible one affordable.
Mikhail Belkin, Daniel Hsu, Siyuan Ma and Soumik Mandal, in PNAS in 2019, describe a "double descent" curve: performance improves again once model capacity goes beyond the point where the model fits its training data exactly. The polynomial fits above sit below that point, where the classical U-shape applies.
A checklist for choosing model complexity
Hold back data the model never sees, and judge it by the error there.
Training and held-out errors both high and close: you are underfitting, so add flexibility.
Training error far below held-out error: you are overfitting, so simplify, regularise or collect more data.
Training error below your estimate of the noise: be suspicious.
When more data arrives, check again; the best complexity can move up.
To practise least-squares and expectation questions, the Fermi Problem Library has a step-by-step solver that explains the reasoning rather than printing an answer.



