Direct spline interpolation of noisy data may result in a curve with unwanted oscillations. This is particularly bad if the slope of the curve is important.
A better approach is to reduce the degrees of freedom for the spline and use the method of least squares to fit the spline to the noisy data. The deegres of freedom are connected to the number of breaks (knots), so the smoothing effect is controlled by the selection of knots.
CONTENTS:
SPLINEFIT
Fits a cubic spline to noisy data. This routine is faster than PPFIT for large problems. Operates on ND arrays in the same way as SPLINE.
PPFIT
Fits a piecewise polynomial of arbitrary order and regularity to noisy data. Sharp data (boundary conditions or conditions at inner points) can also be forced onto the spline. Operates only on vectors, not ND arrays.
PPDIFF
Differentiate piecewise polynomial.
PPINT
Integrate piecewise polynomial.
In my version of SPLINEFIT the unknowns are function value and slope (y,y') for each break/knot. To get a cubic spline with continuous second derivative I add linear constraints for the continuity of y" at each inner break. So the problem solved is actually a least squares problem with equality constraints.
See also IMMOPTIBOX at http://www2.imm.dtu.dk/~hbn/immoptibox by Hans Bruun Nielsen. This is a toolbox for optimization and data fitting and among other useful tools there is a SPLINEFIT tool based on B-splines.
|