The E02 Chapter - Fitting a surface with bicubic splines
A common task in many areas of science is to find a function which approximates a set of data points. The data may contain random perturbations, such as measurement errors, which it is desirable to smooth out.
e02dc computes a bicubic spline approximation to a set of data values, given on a rectangular grid in the x-y plane. A single parameter is specified to control the trade-off between closeness of fit and smoothness of fit. The burden of choosing the positions of the knots between the bicubic pieces of the spline is taken away from the user and handled automatically by e04uc.
A small value for this smoothing parameter, named s in e02dc, will give a closer fit to the data, but the exact meaning of “small” in this context may vary according to the particular data set. In theory, a value of s = 0 will produce an interpolating spline, though in practise that may cause problems of oscillation around the original data.
In this demo, we first create an arbitrary data set consisting of a plane surface with the z coordinate set to 1 for all values of x and y, except at three points where larger z values are chosen. This pathological data set therefore contains three peaks which are difficult to fit a smooth surface through.
The demo makes a brief movie by calling NAG routine e02dc several times, each with a smaller value of the smoothing parameter than the time before, and showing a surface plot of the results. The fitted surface starts off so smooth that it captures none of the detail of the three peaks, but as the smoothing parameter gets smaller, more and more detail is captured.
The original data, and the data approximated
by a smooth bicubic spline