Math - Interpoloation

Linear, Cubic, Bicubic Splines

Posted by Rico's Nerd Cluster on January 26, 2017

Interpolation

“Interpolation” is essentially “how to get through lines and predict the value of a point in between?”. The first step is to connect points. For that, we need a spline. A spline is a function defined piecewise by polynomials.

1D Case

In 1D, You can simply connect points with straight lines (linear interpolation), or you try to draw a quadratic curve, or even with higher order curves.

Source

The second step is to calculate the interpolation value with a kernel matrix. Take 1D linear interpolation for example, if we want to get the interpolation value between 2 points, we have

\[k = \begin{bmatrix} 0.5 & 0.5 \end{bmatrix} \\ P = kx\]

In 1D, if we choose to draw a cubic curve, the first step is we need 4 points, and define the spline: $f(x) = ax^3 + bx^2 + cx + d$

Source

Now, if we want to estimate the value at x=0.5, we need to solve for [a, b, c, d]. We can choose x=[-1, 0, 1, 2], and get

\[\begin{bmatrix} f(-1) \\ f(0) \\ f(1) \\f(2) \end{bmatrix} = \begin{bmatrix} -1 & 1 & -1 & 1 \\ 0 & 0 & 0 & 1 \\ 1 & 1 & 1 & 1 \\ 8 & 4 & 2 & 1 \end{bmatrix} \begin{bmatrix} a \\ b \\ c \\d \end{bmatrix}\]

Then,

\[\begin{bmatrix} d \\ c \\b \\a \end{bmatrix} = \frac{1}{6} \begin{bmatrix} 0 & 6 & 0 & 0 \\ -2 & -3 & 6 & -1 \\ 3 & -6 & 3 & 0 \\ -1 & 3 & -3 & 1 \end{bmatrix} \begin{bmatrix} f(-1) \\ f(0) \\ f(1) \\f(2) \end{bmatrix}\]

Finally, plug x=0.5, y=0.5 into

\[estimate = \begin{bmatrix} a \\ b \\ c \\d \end{bmatrix}^T \begin{bmatrix} x^3 \\ x^2 \\ x \\ 1 \end{bmatrix}^T\]

voila!

Note on differentiability: Cubic splines are very common. they are typically required to be twice differentiable, so the first and second derivatives are continuous. Linear interpolations (splines) can’t enforce differentiablity at connecting points. Higher order splines, like B-splines, Bezier splines, etc., can have higher order derivatives.

2D Case

In 2D interpolations, we will similarly work with 2D kernels.

Source

If we plot the kernel functions:

Source