Bias–Variance Simulator
Too simple a model misses the pattern; too flexible a model fits the noise. That tradeoff is usually drawn as a cartoon U. Here it is computed: one true curve, buried under noise of a stated size, and dozens of fresh samples — a polynomial of every degree from 1 to 10 fitted to each sample, every error measured against the truth itself.
How it works
The sample positions are fixed — the same x values every time; only the noise is redrawn, from a seeded generator (mulberry32), so every ensemble is reproducible. At any point, the ensemble's fits split exactly: the average fit's distance from the truth is bias (the model's rigidity), the fits' spread around their own average is variance (the model's sensitivity to which sample it happened to get), and E[(fit − truth)²] = bias² + variance is algebra, verified pointwise by the site's tests. The error against a new observation adds a third term, σ² — the irreducible noise of the process itself, which no degree, however clever, can reduce.
The grey dashed line is the impostor to watch: training error, each fit scored on the very data it was fitted to. It falls monotonically and, at high degree, dives below the noise floor — a score no honest model can achieve on new data. That dive is overfitting, priced. It is also why the companion posts reach for cross-validation: in real work the truth is not known, so held-out data has to play its role.
Three honest limits, stated plainly. The truth here is known by construction — that is what makes the split measurable, and it is a luxury real modelling does not have. Polynomial degree is one dial of complexity among many — features, trees, kernels, networks (the primary post's zoo) turn the same dial in other units. And the decomposition is stated for squared error; other losses split differently. All math runs client-side and is verified against independently computed reference values — see Software & sources.