Bias-Variance Decomposition
The bias-variance decomposition splits the expected squared error of a learning method at an input into three parts. Assume the responses follow . Here is the true regression function, and the noise has mean and variance . A random training set of samples produces the fitted model . The average predictor averages the fits over all possible training sets. For a new response at , drawn independently of ,
The expectation on the left runs over the training set and the new noise. The three terms on the right are:
- Noise : the spread of around . No model can remove it.
- Squared bias : the error of the average fit. It comes from a model class that is too simple or too constrained.
- Variance : how far one fit strays from the average fit. It comes from flexibility relative to the amount of data.
Averaging each term over from the input distribution turns the left side into the expected test MSE. For vector outputs, each square becomes a squared norm. The decomposition is exact only for squared error.
The bias-variance tradeoff describes what happens as capacity grows with fixed. More parameters, a smaller penalty , fewer neighbors in k-NN or deeper trees lower the bias and raise the variance. The expected test error is then U-shaped in capacity, with its minimum at an intermediate capacity. More training data lowers the variance. It does not remove the bias of a model class that cannot represent . Neither term can be measured from one dataset, since the bias needs and the variance needs many training sets. Once a model has enough capacity to interpolate the training data, test error can fall again. This pattern is called double descent.
Intuition
Picture repeating the whole experiment many times. Each repetition draws a new training set and fits a new model, so the fitted function is random. The word “bias” comes from statistics, where a biased estimator misses the true value on average. Here the average of all the fitted functions, , misses by the bias. The “variance” is the ordinary variance of the fitted value at across repetitions. A straight line fit to a curved trend comes out nearly the same every time. Every copy is wrong in the same places. A high-degree polynomial follows the noise of each training set. Its fits are right on average but wrong in a different direction each time. The noise term is the part of that no function of can predict.
When a modeler raises capacity, the bias falls and the variance rises. The best capacity balances the two, and it depends on and . With more data each fit varies less, so the best capacity grows with .
The animation fits a degree-1 and a degree-9 polynomial to 20 training sets drawn from one curve. The bars split each model’s test MSE into bias squared, variance and noise.
\usepackage{tikz}
\usetikzlibrary{animations, arrows.meta}
\begin{document}
\definecolor{hot}{HTML}{D9483B}
\definecolor{cold}{HTML}{2F80ED}
\definecolor{mid}{HTML}{8A8A8A}
\newcommand{\q}[1]{\filldraw[draw=black, fill=cold] (#1) circle (1.8pt);}
\begin{tikzpicture}[font=\small, >={Stealth[length=2.2mm]}]
\draw (0.0,-1.70) rectangle (6.60,1.70);
\node at (3.30,2.05) {simple model: degree 1};
\draw (0.20,-4.55) -- (6.40,-4.55);
\node[below] at (0.85,-4.55) {\footnotesize bias$^2$};
\node[below] at (2.25,-4.55) {\footnotesize variance};
\node[below] at (3.65,-4.55) {\footnotesize noise $\sigma^2$};
\node[below] at (5.45,-4.55) {\footnotesize test MSE};
\draw (7.9,-1.70) rectangle (14.50,1.70);
\node at (11.20,2.05) {flexible model: degree 9};
\draw (8.10,-4.55) -- (14.30,-4.55);
\node[below] at (8.75,-4.55) {\footnotesize bias$^2$};
\node[below] at (10.15,-4.55) {\footnotesize variance};
\node[below] at (11.55,-4.55) {\footnotesize noise $\sigma^2$};
\node[below] at (13.35,-4.55) {\footnotesize test MSE};
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 1.8s = "true", 22.65s = "true", repeats}}}]
\draw[mid] (0.30,0.86) -- (6.30,-1.08);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 1.8s = "true", 22.65s = "true", repeats}}}]
\draw[mid] (8.20,-1.39) -- (8.33,-0.40) -- (8.47,0.12) -- (8.60,0.38) -- (8.73,0.51) -- (8.87,0.59) -- (9.00,0.65) -- (9.13,0.71) -- (9.27,0.76) -- (9.40,0.81) -- (9.53,0.85) -- (9.67,0.86) -- (9.80,0.84) -- (9.93,0.79) -- (10.07,0.72) -- (10.20,0.62) -- (10.33,0.50) -- (10.47,0.38) -- (10.60,0.25) -- (10.73,0.13) -- (10.87,0.02) -- (11.00,-0.08) -- (11.13,-0.17) -- (11.27,-0.25) -- (11.40,-0.32) -- (11.53,-0.38) -- (11.67,-0.44) -- (11.80,-0.51) -- (11.93,-0.58) -- (12.07,-0.66) -- (12.20,-0.74) -- (12.33,-0.83) -- (12.47,-0.92) -- (12.60,-1.00) -- (12.73,-1.06) -- (12.87,-1.09) -- (13.00,-1.09) -- (13.13,-1.05) -- (13.27,-0.96) -- (13.40,-0.84) -- (13.53,-0.69) -- (13.67,-0.55) -- (13.80,-0.45) -- (13.93,-0.45) -- (14.07,-0.63) -- (14.20,-1.07);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 2.9s = "true", 22.65s = "true", repeats}}}]
\draw[mid] (0.30,0.94) -- (6.30,-0.94);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 2.9s = "true", 22.65s = "true", repeats}}}]
\draw[mid] (8.20,0.34) -- (8.33,0.35) -- (8.47,0.39) -- (8.60,0.44) -- (8.73,0.51) -- (8.87,0.58) -- (9.00,0.65) -- (9.13,0.72) -- (9.27,0.78) -- (9.40,0.84) -- (9.53,0.89) -- (9.67,0.92) -- (9.80,0.93) -- (9.93,0.92) -- (10.07,0.89) -- (10.20,0.83) -- (10.33,0.75) -- (10.47,0.64) -- (10.60,0.52) -- (10.73,0.40) -- (10.87,0.26) -- (11.00,0.13) -- (11.13,0.00) -- (11.27,-0.11) -- (11.40,-0.22) -- (11.53,-0.31) -- (11.67,-0.39) -- (11.80,-0.47) -- (11.93,-0.54) -- (12.07,-0.60) -- (12.20,-0.67) -- (12.33,-0.75) -- (12.47,-0.83) -- (12.60,-0.92) -- (12.73,-1.00) -- (12.87,-1.07) -- (13.00,-1.11) -- (13.13,-1.10) -- (13.27,-1.03) -- (13.40,-0.89) -- (13.53,-0.68) -- (13.67,-0.41) -- (13.80,-0.14) -- (13.93,0.03) -- (14.07,-0.07) -- (14.20,-0.70);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 3.8s = "true", 22.65s = "true", repeats}}}]
\draw[mid] (0.30,0.88) -- (6.30,-0.87);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 3.8s = "true", 22.65s = "true", repeats}}}]
\draw[mid] (8.24,-1.70) -- (8.33,-0.50) -- (8.47,0.19) -- (8.60,0.41) -- (8.73,0.45) -- (8.87,0.45) -- (9.00,0.49) -- (9.13,0.58) -- (9.27,0.70) -- (9.40,0.84) -- (9.53,0.95) -- (9.67,1.03) -- (9.80,1.07) -- (9.93,1.05) -- (10.07,0.99) -- (10.20,0.90) -- (10.33,0.78) -- (10.47,0.65) -- (10.60,0.52) -- (10.73,0.39) -- (10.87,0.28) -- (11.00,0.18) -- (11.13,0.08) -- (11.27,-0.01) -- (11.40,-0.11) -- (11.53,-0.21) -- (11.67,-0.33) -- (11.80,-0.45) -- (11.93,-0.59) -- (12.07,-0.72) -- (12.20,-0.85) -- (12.33,-0.95) -- (12.47,-1.02) -- (12.60,-1.05) -- (12.73,-1.03) -- (12.87,-0.96) -- (13.00,-0.85) -- (13.13,-0.73) -- (13.27,-0.60) -- (13.40,-0.51) -- (13.53,-0.46) -- (13.67,-0.44) -- (13.80,-0.38) -- (13.93,-0.13) -- (14.07,0.59) -- (14.16,1.70);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 3.8s = "true", 22.65s = "true", repeats}}}]
\draw[mid] (0.30,1.01) -- (6.30,-0.95);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 3.8s = "true", 22.65s = "true", repeats}}}]
\draw[mid] (8.20,-0.39) -- (8.33,-0.20) -- (8.47,0.17) -- (8.60,0.53) -- (8.73,0.78) -- (8.87,0.93) -- (9.00,0.97) -- (9.13,0.96) -- (9.27,0.91) -- (9.40,0.86) -- (9.53,0.83) -- (9.67,0.82) -- (9.80,0.83) -- (9.93,0.86) -- (10.07,0.88) -- (10.20,0.89) -- (10.33,0.87) -- (10.47,0.81) -- (10.60,0.71) -- (10.73,0.57) -- (10.87,0.40) -- (11.00,0.20) -- (11.13,-0.01) -- (11.27,-0.21) -- (11.40,-0.39) -- (11.53,-0.55) -- (11.67,-0.66) -- (11.80,-0.73) -- (11.93,-0.76) -- (12.07,-0.76) -- (12.20,-0.74) -- (12.33,-0.72) -- (12.47,-0.70) -- (12.60,-0.71) -- (12.73,-0.74) -- (12.87,-0.79) -- (13.00,-0.86) -- (13.13,-0.91) -- (13.27,-0.92) -- (13.40,-0.86) -- (13.53,-0.71) -- (13.67,-0.49) -- (13.80,-0.28) -- (13.93,-0.24) -- (14.07,-0.70) -- (14.16,-1.70);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 4.05s = "true", 22.65s = "true", repeats}}}]
\draw[mid] (0.30,0.99) -- (6.30,-0.85);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 4.05s = "true", 22.65s = "true", repeats}}}]
\draw[mid] (8.20,-0.06) -- (8.33,0.61) -- (8.47,0.88) -- (8.60,0.96) -- (8.73,0.95) -- (8.87,0.92) -- (9.00,0.89) -- (9.13,0.88) -- (9.27,0.88) -- (9.40,0.89) -- (9.53,0.89) -- (9.67,0.88) -- (9.80,0.86) -- (9.93,0.83) -- (10.07,0.79) -- (10.20,0.73) -- (10.33,0.67) -- (10.47,0.60) -- (10.60,0.52) -- (10.73,0.44) -- (10.87,0.35) -- (11.00,0.25) -- (11.13,0.14) -- (11.27,0.02) -- (11.40,-0.10) -- (11.53,-0.23) -- (11.67,-0.35) -- (11.80,-0.47) -- (11.93,-0.58) -- (12.07,-0.66) -- (12.20,-0.72) -- (12.33,-0.75) -- (12.47,-0.74) -- (12.60,-0.72) -- (12.73,-0.68) -- (12.87,-0.64) -- (13.00,-0.62) -- (13.13,-0.63) -- (13.27,-0.69) -- (13.40,-0.78) -- (13.53,-0.86) -- (13.67,-0.85) -- (13.80,-0.55) -- (13.93,0.33) -- (14.03,1.70);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 4.3s = "true", 22.65s = "true", repeats}}}]
\draw[mid] (0.30,0.98) -- (6.30,-0.99);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 4.3s = "true", 22.65s = "true", repeats}}}]
\draw[mid] (8.35,1.70) -- (8.47,0.90) -- (8.60,0.57) -- (8.73,0.56) -- (8.87,0.69) -- (9.00,0.85) -- (9.13,0.97) -- (9.27,1.04) -- (9.40,1.04) -- (9.53,1.00) -- (9.67,0.92) -- (9.80,0.82) -- (9.93,0.72) -- (10.07,0.61) -- (10.20,0.52) -- (10.33,0.44) -- (10.47,0.36) -- (10.60,0.29) -- (10.73,0.21) -- (10.87,0.14) -- (11.00,0.05) -- (11.13,-0.04) -- (11.27,-0.15) -- (11.40,-0.27) -- (11.53,-0.39) -- (11.67,-0.51) -- (11.80,-0.63) -- (11.93,-0.74) -- (12.07,-0.83) -- (12.20,-0.89) -- (12.33,-0.94) -- (12.47,-0.95) -- (12.60,-0.94) -- (12.73,-0.90) -- (12.87,-0.85) -- (13.00,-0.77) -- (13.13,-0.69) -- (13.27,-0.61) -- (13.40,-0.54) -- (13.53,-0.47) -- (13.67,-0.41) -- (13.80,-0.37) -- (13.93,-0.34) -- (14.07,-0.31) -- (14.20,-0.30);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 4.55s = "true", 22.65s = "true", repeats}}}]
\draw[mid] (0.30,0.92) -- (6.30,-0.82);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 4.55s = "true", 22.65s = "true", repeats}}}]
\draw[mid] (8.20,0.12) -- (8.33,0.50) -- (8.47,0.67) -- (8.60,0.72) -- (8.73,0.72) -- (8.87,0.72) -- (9.00,0.72) -- (9.13,0.73) -- (9.27,0.76) -- (9.40,0.80) -- (9.53,0.84) -- (9.67,0.87) -- (9.80,0.89) -- (9.93,0.89) -- (10.07,0.86) -- (10.20,0.81) -- (10.33,0.74) -- (10.47,0.65) -- (10.60,0.53) -- (10.73,0.41) -- (10.87,0.28) -- (11.00,0.15) -- (11.13,0.02) -- (11.27,-0.11) -- (11.40,-0.23) -- (11.53,-0.33) -- (11.67,-0.42) -- (11.80,-0.50) -- (11.93,-0.56) -- (12.07,-0.61) -- (12.20,-0.65) -- (12.33,-0.68) -- (12.47,-0.69) -- (12.60,-0.71) -- (12.73,-0.71) -- (12.87,-0.71) -- (13.00,-0.71) -- (13.13,-0.69) -- (13.27,-0.67) -- (13.40,-0.64) -- (13.53,-0.59) -- (13.67,-0.52) -- (13.80,-0.42) -- (13.93,-0.30) -- (14.07,-0.13) -- (14.20,0.09);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 4.8s = "true", 22.65s = "true", repeats}}}]
\draw[mid] (0.30,0.74) -- (6.30,-0.75);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 4.8s = "true", 22.65s = "true", repeats}}}]
\draw[mid] (8.20,0.73) -- (8.33,-0.06) -- (8.47,-0.19) -- (8.60,-0.00) -- (8.73,0.27) -- (8.87,0.53) -- (9.00,0.71) -- (9.13,0.81) -- (9.27,0.83) -- (9.40,0.81) -- (9.53,0.77) -- (9.67,0.72) -- (9.80,0.67) -- (9.93,0.65) -- (10.07,0.63) -- (10.20,0.62) -- (10.33,0.61) -- (10.47,0.60) -- (10.60,0.56) -- (10.73,0.49) -- (10.87,0.40) -- (11.00,0.28) -- (11.13,0.13) -- (11.27,-0.03) -- (11.40,-0.20) -- (11.53,-0.36) -- (11.67,-0.51) -- (11.80,-0.63) -- (11.93,-0.71) -- (12.07,-0.75) -- (12.20,-0.74) -- (12.33,-0.70) -- (12.47,-0.64) -- (12.60,-0.56) -- (12.73,-0.47) -- (12.87,-0.41) -- (13.00,-0.37) -- (13.13,-0.37) -- (13.27,-0.42) -- (13.40,-0.50) -- (13.53,-0.60) -- (13.67,-0.69) -- (13.80,-0.73) -- (13.93,-0.66) -- (14.07,-0.45) -- (14.20,-0.03);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 5.05s = "true", 22.65s = "true", repeats}}}]
\draw[mid] (0.30,1.01) -- (6.30,-1.08);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 5.05s = "true", 22.65s = "true", repeats}}}]
\draw[mid] (8.20,-0.15) -- (8.33,0.13) -- (8.47,0.27) -- (8.60,0.34) -- (8.73,0.40) -- (8.87,0.46) -- (9.00,0.54) -- (9.13,0.64) -- (9.27,0.75) -- (9.40,0.86) -- (9.53,0.97) -- (9.67,1.05) -- (9.80,1.11) -- (9.93,1.13) -- (10.07,1.12) -- (10.20,1.07) -- (10.33,0.99) -- (10.47,0.88) -- (10.60,0.74) -- (10.73,0.59) -- (10.87,0.42) -- (11.00,0.25) -- (11.13,0.08) -- (11.27,-0.09) -- (11.40,-0.25) -- (11.53,-0.40) -- (11.67,-0.54) -- (11.80,-0.66) -- (11.93,-0.78) -- (12.07,-0.88) -- (12.20,-0.97) -- (12.33,-1.04) -- (12.47,-1.11) -- (12.60,-1.15) -- (12.73,-1.17) -- (12.87,-1.16) -- (13.00,-1.11) -- (13.13,-1.03) -- (13.27,-0.90) -- (13.40,-0.74) -- (13.53,-0.56) -- (13.67,-0.39) -- (13.80,-0.29) -- (13.93,-0.32) -- (14.07,-0.61) -- (14.20,-1.34);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 5.3s = "true", 22.65s = "true", repeats}}}]
\draw[mid] (0.30,0.72) -- (6.30,-0.66);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 5.3s = "true", 22.65s = "true", repeats}}}]
\draw[mid] (8.20,0.34) -- (8.33,0.11) -- (8.47,0.09) -- (8.60,0.19) -- (8.73,0.32) -- (8.87,0.46) -- (9.00,0.58) -- (9.13,0.68) -- (9.27,0.76) -- (9.40,0.82) -- (9.53,0.87) -- (9.67,0.90) -- (9.80,0.92) -- (9.93,0.91) -- (10.07,0.89) -- (10.20,0.85) -- (10.33,0.78) -- (10.47,0.69) -- (10.60,0.58) -- (10.73,0.45) -- (10.87,0.31) -- (11.00,0.16) -- (11.13,0.00) -- (11.27,-0.14) -- (11.40,-0.28) -- (11.53,-0.40) -- (11.67,-0.49) -- (11.80,-0.57) -- (11.93,-0.62) -- (12.07,-0.65) -- (12.20,-0.66) -- (12.33,-0.67) -- (12.47,-0.66) -- (12.60,-0.65) -- (12.73,-0.63) -- (12.87,-0.62) -- (13.00,-0.60) -- (13.13,-0.57) -- (13.27,-0.53) -- (13.40,-0.45) -- (13.53,-0.35) -- (13.67,-0.23) -- (13.80,-0.09) -- (13.93,-0.00) -- (14.07,-0.05) -- (14.20,-0.39);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 5.55s = "true", 22.65s = "true", repeats}}}]
\draw[mid] (0.30,0.84) -- (6.30,-0.77);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 5.55s = "true", 22.65s = "true", repeats}}}]
\draw[mid] (8.20,0.08) -- (8.33,-0.17) -- (8.47,-0.05) -- (8.60,0.22) -- (8.73,0.50) -- (8.87,0.72) -- (9.00,0.87) -- (9.13,0.95) -- (9.27,0.97) -- (9.40,0.97) -- (9.53,0.94) -- (9.67,0.91) -- (9.80,0.88) -- (9.93,0.86) -- (10.07,0.84) -- (10.20,0.81) -- (10.33,0.76) -- (10.47,0.70) -- (10.60,0.61) -- (10.73,0.49) -- (10.87,0.35) -- (11.00,0.19) -- (11.13,0.02) -- (11.27,-0.16) -- (11.40,-0.33) -- (11.53,-0.49) -- (11.67,-0.62) -- (11.80,-0.71) -- (11.93,-0.77) -- (12.07,-0.80) -- (12.20,-0.79) -- (12.33,-0.76) -- (12.47,-0.72) -- (12.60,-0.67) -- (12.73,-0.64) -- (12.87,-0.63) -- (13.00,-0.64) -- (13.13,-0.67) -- (13.27,-0.71) -- (13.40,-0.74) -- (13.53,-0.73) -- (13.67,-0.65) -- (13.80,-0.46) -- (13.93,-0.12) -- (14.07,0.36) -- (14.20,0.97);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 5.8s = "true", 22.65s = "true", repeats}}}]
\draw[mid] (0.30,0.79) -- (6.30,-0.73);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 5.8s = "true", 22.65s = "true", repeats}}}]
\draw[mid] (8.20,-0.65) -- (8.33,0.03) -- (8.47,0.32) -- (8.60,0.42) -- (8.73,0.46) -- (8.87,0.48) -- (9.00,0.53) -- (9.13,0.61) -- (9.27,0.69) -- (9.40,0.77) -- (9.53,0.84) -- (9.67,0.89) -- (9.80,0.91) -- (9.93,0.89) -- (10.07,0.85) -- (10.20,0.79) -- (10.33,0.71) -- (10.47,0.62) -- (10.60,0.53) -- (10.73,0.43) -- (10.87,0.34) -- (11.00,0.24) -- (11.13,0.16) -- (11.27,0.07) -- (11.40,-0.02) -- (11.53,-0.11) -- (11.67,-0.21) -- (11.80,-0.30) -- (11.93,-0.39) -- (12.07,-0.48) -- (12.20,-0.56) -- (12.33,-0.62) -- (12.47,-0.66) -- (12.60,-0.68) -- (12.73,-0.68) -- (12.87,-0.66) -- (13.00,-0.62) -- (13.13,-0.58) -- (13.27,-0.56) -- (13.40,-0.56) -- (13.53,-0.60) -- (13.67,-0.66) -- (13.80,-0.71) -- (13.93,-0.68) -- (14.07,-0.41) -- (14.20,0.33);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 6.05s = "true", 22.65s = "true", repeats}}}]
\draw[mid] (0.30,0.98) -- (6.30,-0.98);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 6.05s = "true", 22.65s = "true", repeats}}}]
\draw[mid] (8.20,1.57) -- (8.33,1.02) -- (8.47,0.72) -- (8.60,0.59) -- (8.73,0.56) -- (8.87,0.60) -- (9.00,0.66) -- (9.13,0.74) -- (9.27,0.81) -- (9.40,0.86) -- (9.53,0.90) -- (9.67,0.91) -- (9.80,0.89) -- (9.93,0.85) -- (10.07,0.78) -- (10.20,0.69) -- (10.33,0.58) -- (10.47,0.46) -- (10.60,0.33) -- (10.73,0.19) -- (10.87,0.05) -- (11.00,-0.08) -- (11.13,-0.20) -- (11.27,-0.30) -- (11.40,-0.40) -- (11.53,-0.47) -- (11.67,-0.54) -- (11.80,-0.59) -- (11.93,-0.63) -- (12.07,-0.67) -- (12.20,-0.70) -- (12.33,-0.73) -- (12.47,-0.76) -- (12.60,-0.80) -- (12.73,-0.83) -- (12.87,-0.85) -- (13.00,-0.85) -- (13.13,-0.83) -- (13.27,-0.78) -- (13.40,-0.69) -- (13.53,-0.57) -- (13.67,-0.43) -- (13.80,-0.32) -- (13.93,-0.31) -- (14.07,-0.51) -- (14.20,-1.11);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 6.3s = "true", 22.65s = "true", repeats}}}]
\draw[mid] (0.30,0.82) -- (6.30,-0.89);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 6.3s = "true", 22.65s = "true", repeats}}}]
\draw[mid] (8.20,0.08) -- (8.33,0.45) -- (8.47,0.50) -- (8.60,0.44) -- (8.73,0.40) -- (8.87,0.42) -- (9.00,0.49) -- (9.13,0.60) -- (9.27,0.72) -- (9.40,0.82) -- (9.53,0.89) -- (9.67,0.92) -- (9.80,0.90) -- (9.93,0.83) -- (10.07,0.74) -- (10.20,0.62) -- (10.33,0.50) -- (10.47,0.37) -- (10.60,0.26) -- (10.73,0.16) -- (10.87,0.08) -- (11.00,-0.00) -- (11.13,-0.07) -- (11.27,-0.15) -- (11.40,-0.23) -- (11.53,-0.32) -- (11.67,-0.42) -- (11.80,-0.54) -- (11.93,-0.65) -- (12.07,-0.76) -- (12.20,-0.85) -- (12.33,-0.91) -- (12.47,-0.93) -- (12.60,-0.90) -- (12.73,-0.82) -- (12.87,-0.70) -- (13.00,-0.56) -- (13.13,-0.43) -- (13.27,-0.33) -- (13.40,-0.30) -- (13.53,-0.36) -- (13.67,-0.50) -- (13.80,-0.65) -- (13.93,-0.66) -- (14.07,-0.23) -- (14.20,1.12);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 6.55s = "true", 22.65s = "true", repeats}}}]
\draw[mid] (0.30,0.69) -- (6.30,-0.82);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 6.55s = "true", 22.65s = "true", repeats}}}]
\draw[mid] (8.20,-0.01) -- (8.33,0.11) -- (8.47,0.29) -- (8.60,0.48) -- (8.73,0.63) -- (8.87,0.73) -- (9.00,0.79) -- (9.13,0.80) -- (9.27,0.78) -- (9.40,0.74) -- (9.53,0.69) -- (9.67,0.63) -- (9.80,0.57) -- (9.93,0.52) -- (10.07,0.46) -- (10.20,0.41) -- (10.33,0.36) -- (10.47,0.31) -- (10.60,0.25) -- (10.73,0.19) -- (10.87,0.11) -- (11.00,0.03) -- (11.13,-0.06) -- (11.27,-0.16) -- (11.40,-0.26) -- (11.53,-0.37) -- (11.67,-0.47) -- (11.80,-0.57) -- (11.93,-0.66) -- (12.07,-0.73) -- (12.20,-0.79) -- (12.33,-0.82) -- (12.47,-0.84) -- (12.60,-0.84) -- (12.73,-0.82) -- (12.87,-0.78) -- (13.00,-0.73) -- (13.13,-0.66) -- (13.27,-0.60) -- (13.40,-0.52) -- (13.53,-0.45) -- (13.67,-0.37) -- (13.80,-0.30) -- (13.93,-0.22) -- (14.07,-0.15) -- (14.20,-0.08);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 6.8s = "true", 22.65s = "true", repeats}}}]
\draw[mid] (0.30,0.87) -- (6.30,-0.60);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 6.8s = "true", 22.65s = "true", repeats}}}]
\draw[mid] (8.20,0.14) -- (8.33,0.13) -- (8.47,0.33) -- (8.60,0.59) -- (8.73,0.84) -- (8.87,1.02) -- (9.00,1.13) -- (9.13,1.17) -- (9.27,1.14) -- (9.40,1.08) -- (9.53,0.98) -- (9.67,0.87) -- (9.80,0.77) -- (9.93,0.67) -- (10.07,0.58) -- (10.20,0.51) -- (10.33,0.45) -- (10.47,0.40) -- (10.60,0.35) -- (10.73,0.31) -- (10.87,0.27) -- (11.00,0.23) -- (11.13,0.18) -- (11.27,0.12) -- (11.40,0.05) -- (11.53,-0.02) -- (11.67,-0.10) -- (11.80,-0.18) -- (11.93,-0.26) -- (12.07,-0.33) -- (12.20,-0.41) -- (12.33,-0.47) -- (12.47,-0.53) -- (12.60,-0.59) -- (12.73,-0.64) -- (12.87,-0.68) -- (13.00,-0.71) -- (13.13,-0.73) -- (13.27,-0.73) -- (13.40,-0.71) -- (13.53,-0.66) -- (13.67,-0.56) -- (13.80,-0.40) -- (13.93,-0.16) -- (14.07,0.19) -- (14.20,0.65);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 7.05s = "true", 22.65s = "true", repeats}}}]
\draw[mid] (0.30,0.98) -- (6.30,-0.96);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 7.05s = "true", 22.65s = "true", repeats}}}]
\draw[mid] (8.41,1.70) -- (8.47,0.96) -- (8.60,0.41) -- (8.73,0.39) -- (8.87,0.56) -- (9.00,0.75) -- (9.13,0.89) -- (9.27,0.94) -- (9.40,0.94) -- (9.53,0.90) -- (9.67,0.86) -- (9.80,0.82) -- (9.93,0.79) -- (10.07,0.78) -- (10.20,0.78) -- (10.33,0.77) -- (10.47,0.73) -- (10.60,0.67) -- (10.73,0.57) -- (10.87,0.43) -- (11.00,0.25) -- (11.13,0.05) -- (11.27,-0.16) -- (11.40,-0.37) -- (11.53,-0.55) -- (11.67,-0.71) -- (11.80,-0.81) -- (11.93,-0.87) -- (12.07,-0.89) -- (12.20,-0.87) -- (12.33,-0.82) -- (12.47,-0.77) -- (12.60,-0.73) -- (12.73,-0.71) -- (12.87,-0.73) -- (13.00,-0.78) -- (13.13,-0.84) -- (13.27,-0.89) -- (13.40,-0.89) -- (13.53,-0.80) -- (13.67,-0.61) -- (13.80,-0.33) -- (13.93,-0.04) -- (14.07,0.03) -- (14.20,-0.49);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 7.3s = "true", 22.65s = "true", repeats}}}]
\draw[mid] (0.30,0.83) -- (6.30,-0.82);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 7.3s = "true", 22.65s = "true", repeats}}}]
\draw[mid] (8.20,0.14) -- (8.33,0.33) -- (8.47,0.45) -- (8.60,0.52) -- (8.73,0.56) -- (8.87,0.59) -- (9.00,0.61) -- (9.13,0.63) -- (9.27,0.66) -- (9.40,0.68) -- (9.53,0.71) -- (9.67,0.73) -- (9.80,0.74) -- (9.93,0.75) -- (10.07,0.74) -- (10.20,0.72) -- (10.33,0.68) -- (10.47,0.63) -- (10.60,0.56) -- (10.73,0.48) -- (10.87,0.39) -- (11.00,0.29) -- (11.13,0.19) -- (11.27,0.07) -- (11.40,-0.04) -- (11.53,-0.16) -- (11.67,-0.27) -- (11.80,-0.39) -- (11.93,-0.50) -- (12.07,-0.62) -- (12.20,-0.72) -- (12.33,-0.83) -- (12.47,-0.92) -- (12.60,-1.00) -- (12.73,-1.06) -- (12.87,-1.10) -- (13.00,-1.09) -- (13.13,-1.05) -- (13.27,-0.96) -- (13.40,-0.81) -- (13.53,-0.62) -- (13.67,-0.40) -- (13.80,-0.19) -- (13.93,-0.05) -- (14.07,-0.08) -- (14.20,-0.43);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 7.55s = "true", 22.65s = "true", repeats}}}]
\draw[mid] (0.30,1.00) -- (6.30,-0.92);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 7.55s = "true", 22.65s = "true", repeats}}}]
\draw[mid] (8.20,-0.46) -- (8.33,0.41) -- (8.47,0.63) -- (8.60,0.56) -- (8.73,0.41) -- (8.87,0.32) -- (9.00,0.30) -- (9.13,0.37) -- (9.27,0.50) -- (9.40,0.67) -- (9.53,0.83) -- (9.67,0.97) -- (9.80,1.07) -- (9.93,1.12) -- (10.07,1.12) -- (10.20,1.06) -- (10.33,0.96) -- (10.47,0.84) -- (10.60,0.69) -- (10.73,0.53) -- (10.87,0.37) -- (11.00,0.22) -- (11.13,0.07) -- (11.27,-0.06) -- (11.40,-0.19) -- (11.53,-0.30) -- (11.67,-0.41) -- (11.80,-0.51) -- (11.93,-0.61) -- (12.07,-0.69) -- (12.20,-0.77) -- (12.33,-0.83) -- (12.47,-0.87) -- (12.60,-0.89) -- (12.73,-0.89) -- (12.87,-0.87) -- (13.00,-0.83) -- (13.13,-0.79) -- (13.27,-0.74) -- (13.40,-0.70) -- (13.53,-0.66) -- (13.67,-0.59) -- (13.80,-0.42) -- (13.93,-0.04) -- (14.07,0.77) -- (14.15,1.70);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 7.8s = "true", 22.65s = "true", repeats}}}]
\draw[mid] (0.30,0.64) -- (6.30,-0.75);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 7.8s = "true", 22.65s = "true", repeats}}}]
\draw[mid] (8.32,-1.70) -- (8.33,-1.39) -- (8.47,0.10) -- (8.60,0.66) -- (8.73,0.74) -- (8.87,0.63) -- (9.00,0.48) -- (9.13,0.36) -- (9.27,0.31) -- (9.40,0.32) -- (9.53,0.36) -- (9.67,0.42) -- (9.80,0.47) -- (9.93,0.50) -- (10.07,0.50) -- (10.20,0.48) -- (10.33,0.42) -- (10.47,0.35) -- (10.60,0.27) -- (10.73,0.19) -- (10.87,0.11) -- (11.00,0.04) -- (11.13,-0.03) -- (11.27,-0.09) -- (11.40,-0.15) -- (11.53,-0.20) -- (11.67,-0.27) -- (11.80,-0.34) -- (11.93,-0.41) -- (12.07,-0.50) -- (12.20,-0.58) -- (12.33,-0.66) -- (12.47,-0.73) -- (12.60,-0.78) -- (12.73,-0.81) -- (12.87,-0.81) -- (13.00,-0.79) -- (13.13,-0.76) -- (13.27,-0.72) -- (13.40,-0.70) -- (13.53,-0.70) -- (13.67,-0.72) -- (13.80,-0.73) -- (13.93,-0.65) -- (14.07,-0.31) -- (14.20,0.57);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 8.05s = "true", 22.65s = "true", repeats}}}]
\draw[dashed, very thick] (0.30,0.00) -- (0.40,0.09) -- (0.50,0.18) -- (0.60,0.26) -- (0.70,0.35) -- (0.80,0.42) -- (0.90,0.50) -- (1.00,0.57) -- (1.10,0.63) -- (1.20,0.69) -- (1.30,0.74) -- (1.40,0.78) -- (1.50,0.81) -- (1.60,0.83) -- (1.70,0.85) -- (1.80,0.85) -- (1.90,0.85) -- (2.00,0.83) -- (2.10,0.81) -- (2.20,0.78) -- (2.30,0.74) -- (2.40,0.69) -- (2.50,0.63) -- (2.60,0.57) -- (2.70,0.50) -- (2.80,0.42) -- (2.90,0.35) -- (3.00,0.26) -- (3.10,0.18) -- (3.20,0.09) -- (3.30,0.00) -- (3.40,-0.09) -- (3.50,-0.18) -- (3.60,-0.26) -- (3.70,-0.35) -- (3.80,-0.43) -- (3.90,-0.50) -- (4.00,-0.57) -- (4.10,-0.63) -- (4.20,-0.69) -- (4.30,-0.74) -- (4.40,-0.78) -- (4.50,-0.81) -- (4.60,-0.83) -- (4.70,-0.85) -- (4.80,-0.85) -- (4.90,-0.85) -- (5.00,-0.83) -- (5.10,-0.81) -- (5.20,-0.78) -- (5.30,-0.74) -- (5.40,-0.69) -- (5.50,-0.63) -- (5.60,-0.57) -- (5.70,-0.50) -- (5.80,-0.43) -- (5.90,-0.35) -- (6.00,-0.26) -- (6.10,-0.18) -- (6.20,-0.09) -- (6.30,-0.00);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 8.05s = "true", 22.65s = "true", repeats}}}]
\draw[hot, very thick] (0.30,0.87) -- (0.40,0.85) -- (0.50,0.82) -- (0.60,0.79) -- (0.70,0.76) -- (0.80,0.73) -- (0.90,0.70) -- (1.00,0.67) -- (1.10,0.64) -- (1.20,0.61) -- (1.30,0.59) -- (1.40,0.56) -- (1.50,0.53) -- (1.60,0.50) -- (1.70,0.47) -- (1.80,0.44) -- (1.90,0.41) -- (2.00,0.38) -- (2.10,0.35) -- (2.20,0.32) -- (2.30,0.30) -- (2.40,0.27) -- (2.50,0.24) -- (2.60,0.21) -- (2.70,0.18) -- (2.80,0.15) -- (2.90,0.12) -- (3.00,0.09) -- (3.10,0.06) -- (3.20,0.04) -- (3.30,0.01) -- (3.40,-0.02) -- (3.50,-0.05) -- (3.60,-0.08) -- (3.70,-0.11) -- (3.80,-0.14) -- (3.90,-0.17) -- (4.00,-0.20) -- (4.10,-0.23) -- (4.20,-0.25) -- (4.30,-0.28) -- (4.40,-0.31) -- (4.50,-0.34) -- (4.60,-0.37) -- (4.70,-0.40) -- (4.80,-0.43) -- (4.90,-0.46) -- (5.00,-0.49) -- (5.10,-0.51) -- (5.20,-0.54) -- (5.30,-0.57) -- (5.40,-0.60) -- (5.50,-0.63) -- (5.60,-0.66) -- (5.70,-0.69) -- (5.80,-0.72) -- (5.90,-0.75) -- (6.00,-0.78) -- (6.10,-0.80) -- (6.20,-0.83) -- (6.30,-0.86);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 8.05s = "true", 22.65s = "true", repeats}}}]
\draw[dashed, very thick] (8.20,0.00) -- (8.30,0.09) -- (8.40,0.18) -- (8.50,0.26) -- (8.60,0.35) -- (8.70,0.42) -- (8.80,0.50) -- (8.90,0.57) -- (9.00,0.63) -- (9.10,0.69) -- (9.20,0.74) -- (9.30,0.78) -- (9.40,0.81) -- (9.50,0.83) -- (9.60,0.85) -- (9.70,0.85) -- (9.80,0.85) -- (9.90,0.83) -- (10.00,0.81) -- (10.10,0.78) -- (10.20,0.74) -- (10.30,0.69) -- (10.40,0.63) -- (10.50,0.57) -- (10.60,0.50) -- (10.70,0.42) -- (10.80,0.35) -- (10.90,0.26) -- (11.00,0.18) -- (11.10,0.09) -- (11.20,0.00) -- (11.30,-0.09) -- (11.40,-0.18) -- (11.50,-0.26) -- (11.60,-0.35) -- (11.70,-0.43) -- (11.80,-0.50) -- (11.90,-0.57) -- (12.00,-0.63) -- (12.10,-0.69) -- (12.20,-0.74) -- (12.30,-0.78) -- (12.40,-0.81) -- (12.50,-0.83) -- (12.60,-0.85) -- (12.70,-0.85) -- (12.80,-0.85) -- (12.90,-0.83) -- (13.00,-0.81) -- (13.10,-0.78) -- (13.20,-0.74) -- (13.30,-0.69) -- (13.40,-0.63) -- (13.50,-0.57) -- (13.60,-0.50) -- (13.70,-0.43) -- (13.80,-0.35) -- (13.90,-0.26) -- (14.00,-0.18) -- (14.10,-0.09) -- (14.20,-0.00);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 8.05s = "true", 22.65s = "true", repeats}}}]
\draw[hot, very thick] (8.20,0.19) -- (8.30,0.27) -- (8.40,0.34) -- (8.50,0.41) -- (8.60,0.47) -- (8.70,0.53) -- (8.80,0.58) -- (8.90,0.64) -- (9.00,0.68) -- (9.10,0.73) -- (9.20,0.76) -- (9.30,0.80) -- (9.40,0.82) -- (9.50,0.84) -- (9.60,0.85) -- (9.70,0.85) -- (9.80,0.85) -- (9.90,0.83) -- (10.00,0.81) -- (10.10,0.78) -- (10.20,0.73) -- (10.30,0.68) -- (10.40,0.63) -- (10.50,0.56) -- (10.60,0.49) -- (10.70,0.41) -- (10.80,0.33) -- (10.90,0.24) -- (11.00,0.15) -- (11.10,0.06) -- (11.20,-0.03) -- (11.30,-0.13) -- (11.40,-0.21) -- (11.50,-0.30) -- (11.60,-0.38) -- (11.70,-0.46) -- (11.80,-0.53) -- (11.90,-0.59) -- (12.00,-0.65) -- (12.10,-0.69) -- (12.20,-0.73) -- (12.30,-0.77) -- (12.40,-0.79) -- (12.50,-0.80) -- (12.60,-0.81) -- (12.70,-0.82) -- (12.80,-0.81) -- (12.90,-0.80) -- (13.00,-0.78) -- (13.10,-0.76) -- (13.20,-0.74) -- (13.30,-0.71) -- (13.40,-0.67) -- (13.50,-0.62) -- (13.60,-0.57) -- (13.70,-0.50) -- (13.80,-0.41) -- (13.90,-0.30) -- (14.00,-0.15) -- (14.10,0.05) -- (14.20,0.30);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 10.65s = "true", 22.65s = "true", repeats}}}]
\filldraw[draw=black, fill=hot] (0.49,-4.550) rectangle (1.21,-3.313);
\node[above] at (0.85,-3.313) {\footnotesize $0.206$};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 13.45s = "true", 22.65s = "true", repeats}}}]
\filldraw[draw=black, fill=mid] (1.89,-4.550) rectangle (2.61,-4.496);
\node[above] at (2.25,-4.496) {\footnotesize $0.009$};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 16.25s = "true", 22.65s = "true", repeats}}}]
\filldraw[draw=black, fill=cold] (3.29,-4.550) rectangle (4.01,-4.010);
\node[above] at (3.65,-4.010) {\footnotesize $0.090$};
\filldraw[draw=black, fill=hot] (5.09,-4.550) rectangle (5.81,-3.313);
\filldraw[draw=black, fill=mid] (5.09,-3.313) rectangle (5.81,-3.258);
\filldraw[draw=black, fill=cold] (5.09,-3.258) rectangle (5.81,-2.718);
\node[above] at (5.45,-2.718) {\footnotesize $0.305$};
\node at (1.55,-4.25) {$+$};
\node at (2.95,-4.25) {$+$};
\node at (4.55,-4.25) {$=$};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 10.65s = "true", 22.65s = "true", repeats}}}]
\filldraw[draw=black, fill=hot] (8.39,-4.550) rectangle (9.11,-4.512);
\node[above] at (8.75,-4.512) {\footnotesize $0.006$};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 13.45s = "true", 22.65s = "true", repeats}}}]
\filldraw[draw=black, fill=mid] (9.79,-4.550) rectangle (10.51,-3.351);
\node[above] at (10.15,-3.351) {\footnotesize $0.200$};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 16.25s = "true", 22.65s = "true", repeats}}}]
\filldraw[draw=black, fill=cold] (11.19,-4.550) rectangle (11.91,-4.010);
\node[above] at (11.55,-4.010) {\footnotesize $0.090$};
\filldraw[draw=black, fill=hot] (12.99,-4.550) rectangle (13.71,-4.512);
\filldraw[draw=black, fill=mid] (12.99,-4.512) rectangle (13.71,-3.312);
\filldraw[draw=black, fill=cold] (12.99,-3.312) rectangle (13.71,-2.772);
\node[above] at (13.35,-2.772) {\footnotesize $0.296$};
\node at (9.45,-4.25) {$+$};
\node at (10.85,-4.25) {$+$};
\node at (12.45,-4.25) {$=$};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "true", 1.8s = "false", 22.65s = "false", repeats}}}]
\draw[very thick] (0.30,0.86) -- (6.30,-1.08);
\draw[very thick] (8.20,-1.39) -- (8.33,-0.40) -- (8.47,0.12) -- (8.60,0.38) -- (8.73,0.51) -- (8.87,0.59) -- (9.00,0.65) -- (9.13,0.71) -- (9.27,0.76) -- (9.40,0.81) -- (9.53,0.85) -- (9.67,0.86) -- (9.80,0.84) -- (9.93,0.79) -- (10.07,0.72) -- (10.20,0.62) -- (10.33,0.50) -- (10.47,0.38) -- (10.60,0.25) -- (10.73,0.13) -- (10.87,0.02) -- (11.00,-0.08) -- (11.13,-0.17) -- (11.27,-0.25) -- (11.40,-0.32) -- (11.53,-0.38) -- (11.67,-0.44) -- (11.80,-0.51) -- (11.93,-0.58) -- (12.07,-0.66) -- (12.20,-0.74) -- (12.33,-0.83) -- (12.47,-0.92) -- (12.60,-1.00) -- (12.73,-1.06) -- (12.87,-1.09) -- (13.00,-1.09) -- (13.13,-1.05) -- (13.27,-0.96) -- (13.40,-0.84) -- (13.53,-0.69) -- (13.67,-0.55) -- (13.80,-0.45) -- (13.93,-0.45) -- (14.07,-0.63) -- (14.20,-1.07);
\q{0.54,0.03}
\q{0.84,0.60}
\q{1.05,0.59}
\q{1.29,0.58}
\q{1.52,0.92}
\q{1.92,1.06}
\q{2.22,0.35}
\q{2.41,0.62}
\q{2.71,0.24}
\q{3.30,-0.04}
\q{3.50,-0.50}
\q{3.67,-0.32}
\q{4.03,-0.60}
\q{4.49,-0.88}
\q{4.77,-1.12}
\q{5.05,-0.92}
\q{5.22,-1.05}
\q{5.55,-0.95}
\q{5.90,-0.29}
\q{6.02,-0.53}
\q{8.44,0.03}
\q{8.74,0.60}
\q{8.95,0.59}
\q{9.19,0.58}
\q{9.42,0.92}
\q{9.82,1.06}
\q{10.12,0.35}
\q{10.31,0.62}
\q{10.61,0.24}
\q{11.20,-0.04}
\q{11.40,-0.50}
\q{11.57,-0.32}
\q{11.93,-0.60}
\q{12.39,-0.88}
\q{12.67,-1.12}
\q{12.95,-0.92}
\q{13.12,-1.05}
\q{13.45,-0.95}
\q{13.80,-0.29}
\q{13.92,-0.53}
\node[anchor=west] at (-0.1,-5.55) {Draw 20 points from $\sin 2\pi x$ plus noise ($\sigma = 0.3$). Fit both models to them.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 1.8s = "true", 2.9s = "false", 22.65s = "false", repeats}}}]
\draw[very thick] (0.30,0.94) -- (6.30,-0.94);
\draw[very thick] (8.20,0.34) -- (8.33,0.35) -- (8.47,0.39) -- (8.60,0.44) -- (8.73,0.51) -- (8.87,0.58) -- (9.00,0.65) -- (9.13,0.72) -- (9.27,0.78) -- (9.40,0.84) -- (9.53,0.89) -- (9.67,0.92) -- (9.80,0.93) -- (9.93,0.92) -- (10.07,0.89) -- (10.20,0.83) -- (10.33,0.75) -- (10.47,0.64) -- (10.60,0.52) -- (10.73,0.40) -- (10.87,0.26) -- (11.00,0.13) -- (11.13,0.00) -- (11.27,-0.11) -- (11.40,-0.22) -- (11.53,-0.31) -- (11.67,-0.39) -- (11.80,-0.47) -- (11.93,-0.54) -- (12.07,-0.60) -- (12.20,-0.67) -- (12.33,-0.75) -- (12.47,-0.83) -- (12.60,-0.92) -- (12.73,-1.00) -- (12.87,-1.07) -- (13.00,-1.11) -- (13.13,-1.10) -- (13.27,-1.03) -- (13.40,-0.89) -- (13.53,-0.68) -- (13.67,-0.41) -- (13.80,-0.14) -- (13.93,0.03) -- (14.07,-0.07) -- (14.20,-0.70);
\q{0.43,0.33}
\q{0.84,0.67}
\q{0.97,0.39}
\q{1.30,0.72}
\q{1.74,1.19}
\q{1.95,0.74}
\q{2.25,0.80}
\q{2.47,0.64}
\q{2.70,0.65}
\q{3.28,-0.08}
\q{3.33,-0.06}
\q{3.85,-0.40}
\q{4.01,-0.55}
\q{4.49,-1.02}
\q{4.62,-0.61}
\q{5.08,-1.14}
\q{5.27,-1.06}
\q{5.47,-0.98}
\q{5.92,-0.08}
\q{6.20,-0.18}
\q{8.33,0.33}
\q{8.74,0.67}
\q{8.87,0.39}
\q{9.20,0.72}
\q{9.64,1.19}
\q{9.85,0.74}
\q{10.15,0.80}
\q{10.37,0.64}
\q{10.60,0.65}
\q{11.18,-0.08}
\q{11.23,-0.06}
\q{11.75,-0.40}
\q{11.91,-0.55}
\q{12.39,-1.02}
\q{12.52,-0.61}
\q{12.98,-1.14}
\q{13.17,-1.06}
\q{13.37,-0.98}
\q{13.82,-0.08}
\q{14.10,-0.18}
\node[anchor=west] at (-0.1,-5.55) {Draw a new training set from the same curve and fit again.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 2.9s = "true", 3.8s = "false", 22.65s = "false", repeats}}}]
\draw[very thick] (0.30,0.88) -- (6.30,-0.87);
\draw[very thick] (8.24,-1.70) -- (8.33,-0.50) -- (8.47,0.19) -- (8.60,0.41) -- (8.73,0.45) -- (8.87,0.45) -- (9.00,0.49) -- (9.13,0.58) -- (9.27,0.70) -- (9.40,0.84) -- (9.53,0.95) -- (9.67,1.03) -- (9.80,1.07) -- (9.93,1.05) -- (10.07,0.99) -- (10.20,0.90) -- (10.33,0.78) -- (10.47,0.65) -- (10.60,0.52) -- (10.73,0.39) -- (10.87,0.28) -- (11.00,0.18) -- (11.13,0.08) -- (11.27,-0.01) -- (11.40,-0.11) -- (11.53,-0.21) -- (11.67,-0.33) -- (11.80,-0.45) -- (11.93,-0.59) -- (12.07,-0.72) -- (12.20,-0.85) -- (12.33,-0.95) -- (12.47,-1.02) -- (12.60,-1.05) -- (12.73,-1.03) -- (12.87,-0.96) -- (13.00,-0.85) -- (13.13,-0.73) -- (13.27,-0.60) -- (13.40,-0.51) -- (13.53,-0.46) -- (13.67,-0.44) -- (13.80,-0.38) -- (13.93,-0.13) -- (14.07,0.59) -- (14.16,1.70);
\q{0.51,0.00}
\q{0.85,0.33}
\q{1.02,0.62}
\q{1.37,0.67}
\q{1.64,0.86}
\q{2.09,1.30}
\q{2.20,0.90}
\q{2.52,0.22}
\q{2.70,0.94}
\q{3.13,0.24}
\q{3.49,-0.41}
\q{3.88,-0.25}
\q{4.18,-0.67}
\q{4.30,-0.89}
\q{4.80,-1.01}
\q{4.86,-1.10}
\q{5.35,-0.70}
\q{5.45,-0.39}
\q{5.82,-0.49}
\q{6.02,-0.14}
\q{8.41,0.00}
\q{8.75,0.33}
\q{8.92,0.62}
\q{9.27,0.67}
\q{9.54,0.86}
\q{9.99,1.30}
\q{10.10,0.90}
\q{10.42,0.22}
\q{10.60,0.94}
\q{11.03,0.24}
\q{11.39,-0.41}
\q{11.78,-0.25}
\q{12.08,-0.67}
\q{12.20,-0.89}
\q{12.70,-1.01}
\q{12.76,-1.10}
\q{13.25,-0.70}
\q{13.35,-0.39}
\q{13.72,-0.49}
\q{13.92,-0.14}
\node[anchor=west] at (-0.1,-5.55) {Draw a new training set from the same curve and fit again.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 3.8s = "true", 4.05s = "false", 22.65s = "false", repeats}}}]
\q{0.56,0.14}
\q{0.70,0.55}
\q{1.14,0.81}
\q{1.32,1.14}
\q{1.68,0.85}
\q{2.02,0.45}
\q{2.25,1.25}
\q{2.61,0.84}
\q{2.91,0.07}
\q{3.00,0.61}
\q{3.31,-0.00}
\q{3.64,-0.76}
\q{3.96,-0.65}
\q{4.26,-0.85}
\q{4.51,-0.41}
\q{4.87,-1.05}
\q{5.28,-0.81}
\q{5.67,-0.59}
\q{5.80,-0.52}
\q{6.11,-0.40}
\q{8.46,0.14}
\q{8.60,0.55}
\q{9.04,0.81}
\q{9.22,1.14}
\q{9.58,0.85}
\q{9.92,0.45}
\q{10.15,1.25}
\q{10.51,0.84}
\q{10.81,0.07}
\q{10.90,0.61}
\q{11.21,-0.00}
\q{11.54,-0.76}
\q{11.86,-0.65}
\q{12.16,-0.85}
\q{12.41,-0.41}
\q{12.77,-1.05}
\q{13.18,-0.81}
\q{13.57,-0.59}
\q{13.70,-0.52}
\q{14.01,-0.40}
\node[anchor=west] at (-0.1,-5.55) {Repeat for 20 training sets. Each gray curve is one fit. Set $4$.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 4.05s = "true", 4.3s = "false", 22.65s = "false", repeats}}}]
\q{0.31,-0.01}
\q{0.77,0.87}
\q{1.05,1.15}
\q{1.38,0.64}
\q{1.72,0.61}
\q{1.96,1.53}
\q{2.27,0.50}
\q{2.55,0.46}
\q{2.88,0.37}
\q{3.07,0.32}
\q{3.47,0.12}
\q{3.80,-0.33}
\q{3.96,-0.76}
\q{4.50,-0.68}
\q{4.72,-0.78}
\q{5.09,-0.33}
\q{5.19,-0.78}
\q{5.53,-0.95}
\q{5.78,-0.71}
\q{6.01,0.12}
\q{8.21,-0.01}
\q{8.67,0.87}
\q{8.95,1.15}
\q{9.28,0.64}
\q{9.62,0.61}
\q{9.86,1.53}
\q{10.17,0.50}
\q{10.45,0.46}
\q{10.78,0.37}
\q{10.97,0.32}
\q{11.37,0.12}
\q{11.70,-0.33}
\q{11.86,-0.76}
\q{12.40,-0.68}
\q{12.62,-0.78}
\q{12.99,-0.33}
\q{13.09,-0.78}
\q{13.43,-0.95}
\q{13.68,-0.71}
\q{13.91,0.12}
\node[anchor=west] at (-0.1,-5.55) {Repeat for 20 training sets. Each gray curve is one fit. Set $5$.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 4.3s = "true", 4.55s = "false", 22.65s = "false", repeats}}}]
\q{0.58,0.95}
\q{0.71,0.30}
\q{0.95,0.86}
\q{1.20,1.02}
\q{1.52,0.77}
\q{1.86,1.15}
\q{2.23,0.21}
\q{2.58,0.61}
\q{2.99,0.49}
\q{3.27,-0.58}
\q{3.37,-0.36}
\q{3.78,-0.14}
\q{4.18,-0.74}
\q{4.23,-0.98}
\q{4.76,-0.94}
\q{4.92,-0.98}
\q{5.33,-0.54}
\q{5.50,-0.52}
\q{5.89,-0.43}
\q{6.15,-0.30}
\q{8.48,0.95}
\q{8.61,0.30}
\q{8.85,0.86}
\q{9.10,1.02}
\q{9.42,0.77}
\q{9.76,1.15}
\q{10.13,0.21}
\q{10.48,0.61}
\q{10.89,0.49}
\q{11.17,-0.58}
\q{11.27,-0.36}
\q{11.68,-0.14}
\q{12.08,-0.74}
\q{12.13,-0.98}
\q{12.66,-0.94}
\q{12.82,-0.98}
\q{13.23,-0.54}
\q{13.40,-0.52}
\q{13.79,-0.43}
\q{14.05,-0.30}
\node[anchor=west] at (-0.1,-5.55) {Repeat for 20 training sets. Each gray curve is one fit. Set $6$.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 4.55s = "true", 4.8s = "false", 22.65s = "false", repeats}}}]
\q{0.34,0.27}
\q{0.71,0.70}
\q{1.19,0.89}
\q{1.23,0.62}
\q{1.62,0.82}
\q{2.04,0.95}
\q{2.11,0.73}
\q{2.42,0.82}
\q{2.98,0.57}
\q{3.21,-0.12}
\q{3.38,-0.52}
\q{3.74,-0.08}
\q{3.97,-0.55}
\q{4.47,-0.62}
\q{4.78,-1.19}
\q{4.82,-0.41}
\q{5.26,-0.57}
\q{5.46,-0.69}
\q{5.82,-0.50}
\q{6.22,-0.04}
\q{8.24,0.27}
\q{8.61,0.70}
\q{9.09,0.89}
\q{9.13,0.62}
\q{9.52,0.82}
\q{9.94,0.95}
\q{10.01,0.73}
\q{10.32,0.82}
\q{10.88,0.57}
\q{11.11,-0.12}
\q{11.28,-0.52}
\q{11.64,-0.08}
\q{11.87,-0.55}
\q{12.37,-0.62}
\q{12.68,-1.19}
\q{12.72,-0.41}
\q{13.16,-0.57}
\q{13.36,-0.69}
\q{13.72,-0.50}
\q{14.12,-0.04}
\node[anchor=west] at (-0.1,-5.55) {Repeat for 20 training sets. Each gray curve is one fit. Set $7$.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 4.8s = "true", 5.05s = "false", 22.65s = "false", repeats}}}]
\q{0.45,-0.10}
\q{0.89,0.27}
\q{0.94,0.57}
\q{1.43,0.98}
\q{1.64,0.69}
\q{1.94,0.46}
\q{2.36,0.98}
\q{2.44,0.39}
\q{2.85,0.69}
\q{3.07,0.18}
\q{3.40,-0.27}
\q{3.85,-0.62}
\q{4.02,-0.46}
\q{4.44,-0.56}
\q{4.50,-0.86}
\q{5.10,-0.57}
\q{5.39,-0.16}
\q{5.60,-0.62}
\q{5.76,-0.75}
\q{6.20,-0.36}
\q{8.35,-0.10}
\q{8.79,0.27}
\q{8.84,0.57}
\q{9.33,0.98}
\q{9.54,0.69}
\q{9.84,0.46}
\q{10.26,0.98}
\q{10.34,0.39}
\q{10.75,0.69}
\q{10.97,0.18}
\q{11.30,-0.27}
\q{11.75,-0.62}
\q{11.92,-0.46}
\q{12.34,-0.56}
\q{12.40,-0.86}
\q{13.00,-0.57}
\q{13.29,-0.16}
\q{13.50,-0.62}
\q{13.66,-0.75}
\q{14.10,-0.36}
\node[anchor=west] at (-0.1,-5.55) {Repeat for 20 training sets. Each gray curve is one fit. Set $8$.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 5.05s = "true", 5.3s = "false", 22.65s = "false", repeats}}}]
\q{0.59,0.17}
\q{0.71,0.58}
\q{1.07,0.28}
\q{1.37,0.72}
\q{1.58,1.30}
\q{2.02,0.84}
\q{2.40,0.99}
\q{2.58,0.87}
\q{2.73,0.82}
\q{3.24,0.24}
\q{3.50,-0.53}
\q{3.75,-0.45}
\q{4.10,-0.73}
\q{4.28,-1.12}
\q{4.59,-0.95}
\q{4.95,-1.16}
\q{5.12,-1.23}
\q{5.58,-0.53}
\q{5.75,-0.47}
\q{6.08,-0.37}
\q{8.49,0.17}
\q{8.61,0.58}
\q{8.97,0.28}
\q{9.27,0.72}
\q{9.48,1.30}
\q{9.92,0.84}
\q{10.30,0.99}
\q{10.48,0.87}
\q{10.63,0.82}
\q{11.14,0.24}
\q{11.40,-0.53}
\q{11.65,-0.45}
\q{12.00,-0.73}
\q{12.18,-1.12}
\q{12.49,-0.95}
\q{12.85,-1.16}
\q{13.02,-1.23}
\q{13.48,-0.53}
\q{13.65,-0.47}
\q{13.98,-0.37}
\node[anchor=west] at (-0.1,-5.55) {Repeat for 20 training sets. Each gray curve is one fit. Set $9$.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 5.3s = "true", 5.55s = "false", 22.65s = "false", repeats}}}]
\q{0.39,0.14}
\q{0.77,0.40}
\q{0.91,0.14}
\q{1.29,0.96}
\q{1.58,0.67}
\q{1.85,0.98}
\q{2.34,0.77}
\q{2.69,0.58}
\q{2.97,0.51}
\q{3.13,0.02}
\q{3.32,-0.12}
\q{3.70,-0.57}
\q{4.06,-0.70}
\q{4.31,-0.32}
\q{4.72,-0.94}
\q{5.02,-0.52}
\q{5.37,-0.49}
\q{5.54,-0.42}
\q{5.77,-0.24}
\q{6.27,-0.28}
\q{8.29,0.14}
\q{8.67,0.40}
\q{8.81,0.14}
\q{9.19,0.96}
\q{9.48,0.67}
\q{9.75,0.98}
\q{10.24,0.77}
\q{10.59,0.58}
\q{10.87,0.51}
\q{11.03,0.02}
\q{11.22,-0.12}
\q{11.60,-0.57}
\q{11.96,-0.70}
\q{12.21,-0.32}
\q{12.62,-0.94}
\q{12.92,-0.52}
\q{13.27,-0.49}
\q{13.44,-0.42}
\q{13.67,-0.24}
\q{14.17,-0.28}
\node[anchor=west] at (-0.1,-5.55) {Repeat for 20 training sets. Each gray curve is one fit. Set $10$.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 5.55s = "true", 5.8s = "false", 22.65s = "false", repeats}}}]
\q{0.35,-0.07}
\q{0.81,0.39}
\q{1.15,0.94}
\q{1.20,1.06}
\q{1.77,0.76}
\q{1.83,0.73}
\q{2.19,1.10}
\q{2.55,0.79}
\q{2.83,0.58}
\q{3.06,-0.13}
\q{3.52,-0.29}
\q{3.85,-0.60}
\q{3.97,-0.49}
\q{4.25,-1.14}
\q{4.66,-0.52}
\q{4.84,-0.77}
\q{5.38,-0.59}
\q{5.66,-0.83}
\q{5.95,-0.31}
\q{6.12,0.18}
\q{8.25,-0.07}
\q{8.71,0.39}
\q{9.05,0.94}
\q{9.10,1.06}
\q{9.67,0.76}
\q{9.73,0.73}
\q{10.09,1.10}
\q{10.45,0.79}
\q{10.73,0.58}
\q{10.96,-0.13}
\q{11.42,-0.29}
\q{11.75,-0.60}
\q{11.87,-0.49}
\q{12.15,-1.14}
\q{12.56,-0.52}
\q{12.74,-0.77}
\q{13.28,-0.59}
\q{13.56,-0.83}
\q{13.85,-0.31}
\q{14.02,0.18}
\node[anchor=west] at (-0.1,-5.55) {Repeat for 20 training sets. Each gray curve is one fit. Set $11$.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 5.8s = "true", 6.05s = "false", 22.65s = "false", repeats}}}]
\q{0.37,-0.23}
\q{0.76,0.48}
\q{1.20,0.56}
\q{1.25,0.55}
\q{1.75,0.86}
\q{2.03,1.29}
\q{2.28,0.49}
\q{2.56,0.44}
\q{2.86,0.65}
\q{3.03,0.13}
\q{3.47,0.30}
\q{3.90,-0.44}
\q{4.12,-0.62}
\q{4.34,-0.66}
\q{4.63,-0.39}
\q{5.06,-0.65}
\q{5.10,-0.68}
\q{5.46,-0.59}
\q{5.99,-0.67}
\q{6.20,-0.32}
\q{8.27,-0.23}
\q{8.66,0.48}
\q{9.10,0.56}
\q{9.15,0.55}
\q{9.65,0.86}
\q{9.93,1.29}
\q{10.18,0.49}
\q{10.46,0.44}
\q{10.76,0.65}
\q{10.93,0.13}
\q{11.37,0.30}
\q{11.80,-0.44}
\q{12.02,-0.62}
\q{12.24,-0.66}
\q{12.53,-0.39}
\q{12.96,-0.65}
\q{13.00,-0.68}
\q{13.36,-0.59}
\q{13.89,-0.67}
\q{14.10,-0.32}
\node[anchor=west] at (-0.1,-5.55) {Repeat for 20 training sets. Each gray curve is one fit. Set $12$.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 6.05s = "true", 6.3s = "false", 22.65s = "false", repeats}}}]
\q{0.56,0.74}
\q{0.71,0.54}
\q{1.14,0.87}
\q{1.34,0.53}
\q{1.78,1.04}
\q{1.92,1.02}
\q{2.35,0.45}
\q{2.42,0.45}
\q{2.80,0.40}
\q{3.04,0.30}
\q{3.42,-0.86}
\q{3.72,-0.35}
\q{3.97,-0.49}
\q{4.33,-0.79}
\q{4.70,-0.78}
\q{4.97,-0.72}
\q{5.17,-1.04}
\q{5.61,-0.45}
\q{5.91,-0.40}
\q{6.13,-0.39}
\q{8.46,0.74}
\q{8.61,0.54}
\q{9.04,0.87}
\q{9.24,0.53}
\q{9.68,1.04}
\q{9.82,1.02}
\q{10.25,0.45}
\q{10.32,0.45}
\q{10.70,0.40}
\q{10.94,0.30}
\q{11.32,-0.86}
\q{11.62,-0.35}
\q{11.87,-0.49}
\q{12.23,-0.79}
\q{12.60,-0.78}
\q{12.87,-0.72}
\q{13.07,-1.04}
\q{13.51,-0.45}
\q{13.81,-0.40}
\q{14.03,-0.39}
\node[anchor=west] at (-0.1,-5.55) {Repeat for 20 training sets. Each gray curve is one fit. Set $13$.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 6.3s = "true", 6.55s = "false", 22.65s = "false", repeats}}}]
\q{0.44,0.39}
\q{0.63,0.63}
\q{1.01,0.27}
\q{1.35,0.61}
\q{1.61,1.12}
\q{1.83,0.92}
\q{2.37,0.71}
\q{2.45,0.16}
\q{2.92,-0.14}
\q{3.13,0.34}
\q{3.45,-0.04}
\q{3.80,-0.50}
\q{3.91,-0.61}
\q{4.35,-1.20}
\q{4.64,-0.74}
\q{4.93,-0.58}
\q{5.10,-0.39}
\q{5.40,-0.67}
\q{5.85,-0.44}
\q{6.14,-0.42}
\q{8.34,0.39}
\q{8.53,0.63}
\q{8.91,0.27}
\q{9.25,0.61}
\q{9.51,1.12}
\q{9.73,0.92}
\q{10.27,0.71}
\q{10.35,0.16}
\q{10.82,-0.14}
\q{11.03,0.34}
\q{11.35,-0.04}
\q{11.70,-0.50}
\q{11.81,-0.61}
\q{12.25,-1.20}
\q{12.54,-0.74}
\q{12.83,-0.58}
\q{13.00,-0.39}
\q{13.30,-0.67}
\q{13.75,-0.44}
\q{14.04,-0.42}
\node[anchor=west] at (-0.1,-5.55) {Repeat for 20 training sets. Each gray curve is one fit. Set $14$.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 6.55s = "true", 6.8s = "false", 22.65s = "false", repeats}}}]
\q{0.40,0.08}
\q{0.75,0.42}
\q{0.92,0.91}
\q{1.43,0.42}
\q{1.69,0.91}
\q{1.87,0.69}
\q{2.35,0.42}
\q{2.56,-0.01}
\q{2.98,0.44}
\q{3.25,-0.20}
\q{3.33,-0.22}
\q{3.67,-0.20}
\q{4.15,-0.94}
\q{4.21,-0.69}
\q{4.54,-0.84}
\q{5.08,-0.61}
\q{5.34,-0.46}
\q{5.48,-0.87}
\q{5.80,-0.19}
\q{6.01,-0.28}
\q{8.30,0.08}
\q{8.65,0.42}
\q{8.82,0.91}
\q{9.33,0.42}
\q{9.59,0.91}
\q{9.77,0.69}
\q{10.25,0.42}
\q{10.46,-0.01}
\q{10.88,0.44}
\q{11.15,-0.20}
\q{11.23,-0.22}
\q{11.57,-0.20}
\q{12.05,-0.94}
\q{12.11,-0.69}
\q{12.44,-0.84}
\q{12.98,-0.61}
\q{13.24,-0.46}
\q{13.38,-0.87}
\q{13.70,-0.19}
\q{13.91,-0.28}
\node[anchor=west] at (-0.1,-5.55) {Repeat for 20 training sets. Each gray curve is one fit. Set $15$.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 6.8s = "true", 7.05s = "false", 22.65s = "false", repeats}}}]
\q{0.42,0.15}
\q{0.60,0.33}
\q{1.07,1.24}
\q{1.48,1.11}
\q{1.51,0.89}
\q{1.94,0.89}
\q{2.30,0.19}
\q{2.55,0.80}
\q{2.73,0.29}
\q{3.15,0.17}
\q{3.32,0.00}
\q{3.62,-0.04}
\q{4.00,-0.05}
\q{4.25,-0.46}
\q{4.65,-0.52}
\q{5.08,-0.87}
\q{5.16,-0.67}
\q{5.70,-0.31}
\q{5.80,-0.79}
\q{6.25,0.48}
\q{8.32,0.15}
\q{8.50,0.33}
\q{8.97,1.24}
\q{9.38,1.11}
\q{9.41,0.89}
\q{9.84,0.89}
\q{10.20,0.19}
\q{10.45,0.80}
\q{10.63,0.29}
\q{11.05,0.17}
\q{11.22,0.00}
\q{11.52,-0.04}
\q{11.90,-0.05}
\q{12.15,-0.46}
\q{12.55,-0.52}
\q{12.98,-0.87}
\q{13.06,-0.67}
\q{13.60,-0.31}
\q{13.70,-0.79}
\q{14.15,0.48}
\node[anchor=west] at (-0.1,-5.55) {Repeat for 20 training sets. Each gray curve is one fit. Set $16$.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 7.05s = "true", 7.3s = "false", 22.65s = "false", repeats}}}]
\q{0.60,0.71}
\q{0.70,0.48}
\q{0.93,0.54}
\q{1.27,0.74}
\q{1.55,1.01}
\q{1.92,1.08}
\q{2.32,0.39}
\q{2.63,0.60}
\q{2.73,0.91}
\q{3.05,0.41}
\q{3.41,-0.29}
\q{3.85,-0.64}
\q{4.05,-1.12}
\q{4.36,-0.96}
\q{4.59,-0.42}
\q{4.96,-0.86}
\q{5.28,-0.96}
\q{5.50,-0.78}
\q{5.88,-0.39}
\q{6.23,-0.09}
\q{8.50,0.71}
\q{8.60,0.48}
\q{8.83,0.54}
\q{9.17,0.74}
\q{9.45,1.01}
\q{9.82,1.08}
\q{10.22,0.39}
\q{10.53,0.60}
\q{10.63,0.91}
\q{10.95,0.41}
\q{11.31,-0.29}
\q{11.75,-0.64}
\q{11.95,-1.12}
\q{12.26,-0.96}
\q{12.49,-0.42}
\q{12.86,-0.86}
\q{13.18,-0.96}
\q{13.40,-0.78}
\q{13.78,-0.39}
\q{14.13,-0.09}
\node[anchor=west] at (-0.1,-5.55) {Repeat for 20 training sets. Each gray curve is one fit. Set $17$.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 7.3s = "true", 7.55s = "false", 22.65s = "false", repeats}}}]
\q{0.34,0.21}
\q{0.84,0.66}
\q{0.91,0.46}
\q{1.45,0.65}
\q{1.71,0.87}
\q{1.94,0.69}
\q{2.24,0.43}
\q{2.47,0.97}
\q{2.98,0.05}
\q{3.08,0.65}
\q{3.38,0.06}
\q{3.83,-0.56}
\q{4.07,-0.50}
\q{4.36,-0.45}
\q{4.67,-1.19}
\q{4.83,-1.09}
\q{5.13,-1.07}
\q{5.69,-0.46}
\q{5.91,-0.23}
\q{6.18,-0.10}
\q{8.24,0.21}
\q{8.74,0.66}
\q{8.81,0.46}
\q{9.35,0.65}
\q{9.61,0.87}
\q{9.84,0.69}
\q{10.14,0.43}
\q{10.37,0.97}
\q{10.88,0.05}
\q{10.98,0.65}
\q{11.28,0.06}
\q{11.73,-0.56}
\q{11.97,-0.50}
\q{12.26,-0.45}
\q{12.57,-1.19}
\q{12.73,-1.09}
\q{13.03,-1.07}
\q{13.59,-0.46}
\q{13.81,-0.23}
\q{14.08,-0.10}
\node[anchor=west] at (-0.1,-5.55) {Repeat for 20 training sets. Each gray curve is one fit. Set $18$.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 7.55s = "true", 7.8s = "false", 22.65s = "false", repeats}}}]
\q{0.50,0.59}
\q{0.73,0.47}
\q{1.05,0.33}
\q{1.46,0.73}
\q{1.62,0.73}
\q{1.83,0.91}
\q{2.30,1.02}
\q{2.41,1.21}
\q{2.85,0.46}
\q{3.11,0.08}
\q{3.43,-0.07}
\q{3.82,-0.41}
\q{4.15,-0.75}
\q{4.49,-0.78}
\q{4.73,-0.82}
\q{5.05,-1.10}
\q{5.38,-0.53}
\q{5.52,-0.69}
\q{5.80,-0.65}
\q{6.01,-0.11}
\q{8.40,0.59}
\q{8.63,0.47}
\q{8.95,0.33}
\q{9.36,0.73}
\q{9.52,0.73}
\q{9.73,0.91}
\q{10.20,1.02}
\q{10.31,1.21}
\q{10.75,0.46}
\q{11.01,0.08}
\q{11.33,-0.07}
\q{11.72,-0.41}
\q{12.05,-0.75}
\q{12.39,-0.78}
\q{12.63,-0.82}
\q{12.95,-1.10}
\q{13.28,-0.53}
\q{13.42,-0.69}
\q{13.70,-0.65}
\q{13.91,-0.11}
\node[anchor=west] at (-0.1,-5.55) {Repeat for 20 training sets. Each gray curve is one fit. Set $19$.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 7.8s = "true", 8.05s = "false", 22.65s = "false", repeats}}}]
\q{0.58,0.22}
\q{0.89,0.59}
\q{1.00,0.70}
\q{1.39,0.48}
\q{1.53,0.12}
\q{2.07,0.57}
\q{2.12,0.44}
\q{2.49,0.51}
\q{2.87,0.08}
\q{3.07,0.00}
\q{3.43,0.02}
\q{3.71,-0.31}
\q{4.10,-0.62}
\q{4.36,-0.32}
\q{4.75,-0.95}
\q{4.99,-0.91}
\q{5.32,-0.38}
\q{5.40,-0.95}
\q{5.90,-0.74}
\q{6.27,0.33}
\q{8.48,0.22}
\q{8.79,0.59}
\q{8.90,0.70}
\q{9.29,0.48}
\q{9.43,0.12}
\q{9.97,0.57}
\q{10.02,0.44}
\q{10.39,0.51}
\q{10.77,0.08}
\q{10.97,0.00}
\q{11.33,0.02}
\q{11.61,-0.31}
\q{12.00,-0.62}
\q{12.26,-0.32}
\q{12.65,-0.95}
\q{12.89,-0.91}
\q{13.22,-0.38}
\q{13.30,-0.95}
\q{13.80,-0.74}
\q{14.17,0.33}
\node[anchor=west] at (-0.1,-5.55) {Repeat for 20 training sets. Each gray curve is one fit. Set $20$.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 8.05s = "true", 10.65s = "false", 22.65s = "false", repeats}}}]
\node[anchor=west] at (-0.1,-5.55) {Red: the average of the 20 fits. Dashed: the true curve.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 10.65s = "true", 13.45s = "false", 22.65s = "false", repeats}}}]
\node[anchor=west] at (-0.1,-5.55) {Bias$^2$: the squared gap between red and dashed, averaged over a grid of 101 values of $x$.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 13.45s = "true", 16.25s = "false", 22.65s = "false", repeats}}}]
\node[anchor=west] at (-0.1,-5.55) {Variance: how far the gray fits spread around the red average, averaged over $x$.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 16.25s = "true", 19.05s = "false", 22.65s = "false", repeats}}}]
\node[anchor=west] at (-0.1,-5.55) {Noise $\sigma^2 = 0.09$ is the same for both. The three parts add up to the test MSE.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 19.05s = "true", 22.65s = "true", repeats}}}]
\node[anchor=west] at (-0.1,-5.55) {Degree 1: high bias, low variance. Degree 9: low bias, high variance.};
\end{scope}
\node[anchor=west] at (-0.1,-6.05) {\footnotesize blue: one training set, \ gray: one fit per set, \ red: average fit, \ dashed: true curve $\sin 2\pi x$};
\end{tikzpicture}
\end{document}Properties
(Shrinkage Trades Variance for Bias) A small amount of ridge shrinkage always lowers the expected squared error of a least-squares coefficient.
Take one feature, no intercept, fixed inputs with , and responses . Ridge regression with penalty gives . Its bias and variance are
The size of the bias grows from at , and the variance falls from the least-squares value . Their combination has a negative slope at . Its minimum lies at . The best penalty grows with the noise variance and shrinks as the true weight grows. With many features, the same calculation applies along each singular direction of . A squared singular value then takes the place of . Directions with small singular values have the largest variance and gain the most from shrinkage. The best depends on the unknown , so in practice cross-validation chooses it.
(Diagnosing Bias and Variance) Plots of training and validation error against capacity or against show which term dominates.
High bias shows as a training error that is already high, with the validation error close to it. More data then changes little, and the remedy is more capacity or better features. High variance shows as a low training error and a large gap to the validation error. More data, more regularization or a smaller model then help. A learning curve plots both errors against . Under high bias the two curves meet early at a high level. Under high variance they approach each other slowly from far apart. Consider least squares with coefficients and fixed inputs. The variance of its fitted values, averaged over the training inputs, is exactly . This equals times the trace of the hat matrix. Doubling halves it, while the bias of a misspecified linear model does not shrink to zero.
(Other Losses Do Not Split Additively) For 0-1 loss, bias and variance interact, and extra variance can even raise accuracy.
The derivation below drops a cross term that is zero only for squared error. For classification with 0-1 loss, consider an input where the average model predicts the wrong class. Random variation pushes some fits across the decision threshold to the correct class. More variance then lowers the error at that input. Where the average model is right, variance only hurts. Friedman (1997) and Domingos (2000) give decompositions for 0-1 loss that capture this interaction. For cross-entropy and other losses, noise, bias and variance still cause error, but their contributions do not add.
(Double Descent) In over-parameterized models, test error can fall a second time after a peak at the interpolation threshold.
Not Taught in Lecture
Double descent comes from Prince, Understanding Deep Learning, section 8.4, and from Belkin et al. (2019) and Nakkiran et al. (2021).
The classical U-shaped curve describes models with fewer parameters than training points. As the parameter count approaches , the model can barely fit every point. Only one fit passes through the data, and it has sharp bends between the points. Test error peaks there, at the interpolation threshold. Past the threshold, many fits interpolate the data, and the training algorithm picks one of them. Gradient descent on least squares, started from zero, converges to the minimum-norm interpolating solution. That solution becomes smoother as parameters are added, and test error falls again. Label noise raises the peak. In linear regression, an optimally tuned ridge penalty can remove the peak (Nakkiran et al., 2020). The peak also appears as training time or the number of samples varies. Near the threshold, adding training data can therefore raise test error.
Derivation
Fix and abbreviate , and . The first step separates the noise. Since ,
The new noise has mean zero and is independent of , so . Taking expectations leaves . The second step adds and subtracts the average predictor inside the remaining square:
The factor does not depend on , so it moves outside the expectation. The middle term vanishes because by definition. What remains is the variance plus the squared bias. Adding from the first step gives the decomposition in the callout. The second step is the identity from second-order moments, applied to . For vector outputs, the same steps hold with inner products. The cross term becomes , which is again zero.
Examples
(Easy) Decomposing the Error for One House
A model predicts the sale price of one house, in thousands of dollars. The true expected price is , and sale prices scatter around it with standard deviation . The model is retrained on five equally likely training sets and predicts , , , and .
Compute the noise, squared bias and variance. Which change would help most? , so the bias is and the squared bias is . The deviations from are and , so the variance is . The noise is . The expected squared error is , an RMSE of about thousand dollars. The squared bias is the largest term, so a more flexible model or better features would help most. More data would shrink only the , and no change can remove the .
The average prediction is
(Medium) Tuning Shrinkage for a Sensor
A sensor reading maps to a temperature through , with true and noise variance . Five calibration readings give . An engineer fits ridge regression without an intercept.
Find the bias, variance and expected squared error of for . Which penalty is best? The formulas from the shrinkage property give the following values:
Bias Squared bias Variance Expected squared error The best penalty is . It cuts the expected squared error by about relative to least squares. At the error is back at , since the added bias cancels the saved variance. A simulation with noise draws reproduces these values. The engineer does not know , so in practice cross-validation would estimate the best .
(Hard) Variance Near the Interpolation Threshold
A model fits training points with features. Every feature is drawn independently from , and the labels carry noise of variance . To isolate the variance, take the true weights to be , so every fitted weight comes from noise. For the fit is least squares. For it is the minimum-norm interpolating solution , where is the pseudoinverse. For a test input with independent standard normal features, the excess test error equals . Hastie et al. (2022) give for and for .
Evaluate the variance at . Where does it peak, and why does it fall again? The formulas give the following values, and simulations with thousands of draws per match them:
10 40 48 52 60 200 1000 Variance 0.256 4.44 48 50 5.56 0.336 0.053 Below the threshold, each added feature is another coefficient estimated from the same 50 points, so the variance rises. Near the matrix is almost square and has some tiny singular values. Least squares divides the noise by these singular values, which inflates the weights. Above the threshold, the minimum-norm solution spreads the noise over many more directions, so each weight stays small. The variance then falls like . Now let the true be nonzero with a uniformly random direction. The min-norm fit then also has a squared bias of . It recovers only the projection of onto an -dimensional subspace. Whether test error has a second descent depends on how this bias grows against the falling variance.
See Also
- 2.3. Generalization, for overfitting, underfitting and held-out error.
- 3.2. Regularization, which lowers variance at the cost of bias.
- 5.2. Random Forests, which average many high-variance trees to lower the variance.
- 5.3. Gradient Boosted Trees, which add shallow trees one at a time to lower the bias.
- 4.5. k-Nearest Neighbors, where the number of neighbors sets the tradeoff directly.
- 2.1.1. Mean Squared Error, the loss for which the decomposition is exact.