Search code examples
mathcompressioninterpolationsampling

Minimising interpolation error between two data sets


In the top of the diagrams below we can see some value (y-axis) changing over time (x-axis).

As this happens we are sampling the value at different and unpredictable times, also we are alternating the sampling between two data sets, indicated by red and blue.

When computing the value at any time, we expect that both red and blue data sets will return similar values. However as shown in the three smaller boxes this is not the case. Viewed over time the values from each data set (red and blue) will appear to diverge and then converge about the original value.

diagrams showing the error in interpolation

Initially I used linear interpolation to obtain a value, next I tried using Catmull-Rom interpolation. The former results in a values come close together and then drift apart between each data point; the latter results in values which remain closer, but where the average error is greater.

Can anyone suggest another strategy or interpolation method which will provide greater smoothing (perhaps by using a greater number of sample points from each data set)?


Solution

  • Try B-splines: Catmull-Rom interpolates (goes through the data points), B-spline does smoothing.
    For example, for uniformly-spaced data (not your case)

    Bspline(t) = (data(t-1) + 4*data(t) + data(t+1)) / 6
    

    Of course the interpolated red / blue curves depend on the spacing of the red / blue data points, so cannot match perfectly.