Bias and variance: \(\sin(\pi x)\) with a constant and with a parabola
Companion to Lecture 3, Sections 1–3. Target \(T(x) = \sin(\pi x)\). Each dataset \(\mathcal{D}\) has \(P\) patterns \(x^{(i)} \sim U[-1, 1]\) with labels \(y^{(i)} = T(x^{(i)})\) (deterministic supervisor). We draw \(N_D = 5000\) datasets, fit each by least squares to get \(\hat f^{(\mathcal{D})}\), and average the fits into the average model \(\bar f\).
\(\text{bias}^2 = \mathbb{E}_x\big[(\bar f - T)^2\big]\), \(\text{variance} = \mathbb{E}_x\big[\mathrm{var}_{\mathcal{D}}\, \hat f^{(\mathcal{D})}\big]\), and \(\text{Total MSE} = \text{bias}^2 + \text{variance}\) (Section 2), with \(\mathbb{E}_x\) the average over \(x \sim U[-1, 1]\).
Small \(P\): the parabola can bend to follow every dataset, so its fits spread widely: variance dominates and the constant wins.
Large \(P\): the variance of both models shrinks, but the constant is stuck at \(\text{bias}^2 = 1/2\) (since \(T\) is odd, \(\bar f = 0\)). The parabola reaches \(\text{bias}^2 \to 1/2 - 3/\pi^2 \approx 0.20\), at \(\theta_1 = 3/\pi\), \(\theta_2 = 0\), and wins.
Against \(P\): both variances fall as \(P\) grows, like \(1/P\) for large \(P\), while each bias² levels off: 0.5 for the constant, 0.20 for the parabola. The variance of the constant is \((1/2)/P\): \(\theta_0\) is the mean of \(P\) values of \(T\), and \(\mathrm{var}_x\, T = 1/2\).
The best \(\mathcal{H}\) depends on how much data we have, not only on the target.
Try: \(P = 2\), then \(P = 5, 8, 9, 15\): where do the two Total MSEs cross? Why is the bias² of \(\mathcal{H}_2\) at \(P = 2\) larger than its limit 0.20?
Abu-Mostafa, Magdon-Ismail & Lin, Learning From Data, AMLBook 2012, Section 2.3 (the same experiment with a constant and a line)