The SplineFit06.lng Model

LINGO model to fit a spline interpolation curve to a set of points.

View the model
Download the model

Roughly speaking, find the smoothest curve that goes through all the given (x, y) points. In any interval i, between two adjacent given points, a cubic polynomial is derived to interpolate between the two points.
 1) NOBS = number of observations,
 2) X(i) for i = 1, 2, ..., N,for each observation,
 The X values of the set of points.
 These should be in increasing order.
 3) Y(i) for i = 1, 2, ..., N, . The Y values of the set of points.
 5) NERR = error code, = 0 if all OK, >0 if error, e.g., points are not in increasing order.
 6) A(i) for i = 1, 2, ..., N-1,
 7) B(i) for i = 1, 2, ..., N-1,
 8) C(i) for i = 1, 2, ..., N-1,
 9) D(i) for i = 1, 2, ..., N-1,

Given a specific XS, X(i)<= XS <= X(i+1), the predicted(or corrected or adjusted) estimate of Y is given by:
delta = XS - X(i1),
Predict = D(i1)*delta^3 + C(i1)*delta^2 + B(i1)*delta + A(i1),
Roughly speaking, a spline, Y = F(X), is the "smoothest possible" curve that
 a) passes through each of a given set of points. I.e., If X is the measured value at one of the given points, then F(X) = the true value at that point.
 b) is continuous everywhere, i.e., F(X) has no jumps.
 c) is smooth, i.e., the first derivative is continuous,- it has no abrupt changes, F(x) has no sharp changes.
 d) the second derivative is continuous everywhere, e.g., F(x) is not "curvy" in one interval and then abruptly straight in the next interval ;


Interpolation | Spline Fit |