As a part of Introduction to Numerical Methods1 various methods of interpolation are introduced and have to be implemented: Linear, Cubic (Quintic) Spline, Nearest Neighbour, Lagrange, which by the way is a good way to gain insight into their details. However, even if one has implemented them it is difficult to know their domain of application and which is superior than other, that is why I find it difficult to answer the following question:

Where using nearest neighbour interpolation is superior to cubic spline interpolation?

From what I've understood, the former interpolates by assigning the value of the nearest point which leads to a discretization in the result (interpolated data is consisted of intervals with the same values as the initial data, somehow extended),

enter image description here

while the latter is much more complex method that involves finding the coefficients of a set of $3^{rd}$ order polynomials defined on consecutive intervals determined by the data, by applying sets of constraints2 and solving the system of linear equations for the unknown coefficients, which are then used to evaluate a polynomial (interpolate) at specific point. In this way the result of the last method is "smoother" (difference from one point to another is small).

enter image description here

How do we define and measure how "good" is a method of interpolation and specifically how do we determine (in what circumstances?) which is better/superior between nearest neighbour and cubic spline?

1. Using MATLAB / Octave.

2. Mainly three groups of constraints: each polynomial must pass through the two points determining the interval of its definition; the first, second, etc derivatives of every two consecutive polynomials must be equal at each of their end points (smooth connections of the polynomials); derivative at global end points must be equal to some value (e.g. $0$)

3. Both Interpolations are performed on the same data.

  • 1
    $\begingroup$ Apart from the quality of the interpolation sometimes feasibility is another problem. In most cases in the industry, you need to interpolate experimental data. And sometimes you have to do that on a microcontroller. There you are limited in both processor power and storage space. So maybe a cheap and fast method has to be sufficient, because of that restriction. $\endgroup$ – P. Siehr Sep 27 '17 at 13:16
  • 1
    $\begingroup$ I forgot to mention, that you sometimes have to do that as quick as possible, e.g. in a controller for a motor. Then we measure "good" even more different. $\endgroup$ – P. Siehr Sep 27 '17 at 14:54

Because cubic spline matches the values and derivatives at each of the sample points and enforces continuity of the second derivative at those points, its weakness will be exposed on functions where the first two derivatives change radically (or the second derivative does not exist) at or near the chosen sample points.

An example function would be if you used $4$ intermediate points (at $1,2,3,4$) to approximate the continuous (but not smooth) function $$ y(x) = \left\{ \begin{array}{ll} 1 & 0<x<1 \\ x & 1<x<1.99 \\ 5.97-2x & 1.99<x<3.01 \\ x-3.06 & 3.01<x<4 \\ 4x -15.06 & 4<x<5 \end{array} \right. $$ If you were to use the nearest point interpolations you would obtain values which are considerably off but at least in the plausible range.

If you used the cubic spline, the attempt to match second derivatives will lead to wildly fluctuating cubic functions within each interval, such that the values obtained will often be completely implausible. And those values would be quite different depending on the end-conditions imposed.

| cite | improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.