Q&A: Why can Any Set of Data Points with Different Inputs be Fit Perfectly by a Polynomial of Sufficient Degree?
Cross-posted from here.
Want to get notified about new posts? Join the mailing list and follow on X/Twitter.
In general, if you have a $n$th-degree polynomial $p(x) = a_0 + a_1 x + \ldots + a_n x^n,$ and you’re fitting it to the set of $m$ data points ${ (x_1,y_1), \ldots, (x_m,y_m) },$ then you’re trying to solve the following system of linear equations:
Let’s write this using vectors:
And simplify a bit:
In other words, a solution exists if the $y$-vector is in the span of the $x$-vectors:
Since the $y$-values are arbitrary, this is equivalent to saying that the $x$-vectors span all possible $y$-vectors in $\mathbb{R}^m{:}$
You can span $\mathbb{R}^m$ with and only with a set of $m$ independent vectors in $\mathbb{R}^m.$ So, let’s count off $m$ vectors:
- The $1$st vector is $\begin{bmatrix} 1 \\ \vdots \\ 1 \end{bmatrix}$ which you can think of as $\begin{bmatrix} x_1^0 \\ \vdots \\ x_m^0 \end{bmatrix},$
- the components of the $2$nd vector $\begin{bmatrix} x_1 \\ \vdots \\ x_m \end{bmatrix},$ i.e. $\begin{bmatrix} x_1^1 \\ \vdots \\ x_m^1 \end{bmatrix},$ have exponents $1,$
- the components of the $3$rd vector (not shown above, but it would be $\begin{bmatrix} x_1^2 \\ \vdots \\ x_m^2 \end{bmatrix}$) have exponents $2,$
- ...
- the components of the $m$th vector have exponents $m-1.$
So, you’re guaranteed a perfect fit if $n$ is at least $m-1.$
In other words, any set of $m$ data points with different inputs can be fit perfectly by a polynomial whose degree is at least $m-1.$
Want to get notified about new posts? Join the mailing list and follow on X/Twitter.