Spline Toolbox
  Go to function:
    Search    Help Desk 
csaps    See Also

Cubic smoothing spline

Syntax

Description

The cubic smoothing spline s to the given data x,y is constructed, for the specified smoothing parameter p [0..1] and the optionally specified weight w. The smoothing spline minimizes

with w=ones(size(x)) the default value for w. For p = 0, s is the least-squares straight line fit to the data, while, on the other extreme, i.e., for p = 1, s is the variational, or natural cubic spline interpolant. As p moves from 0 to 1, the smoothing spline changes from one extreme to the other. The interesting range of p is often near 1/(1+h3/6), with h the average spacing of the data abscissae. For uniformly spaced data, one would expect a close following of the data for p = 1/(1 + h3/60) and some satisfactory smoothing for p = 1/(1 + h3/.6).

The call csaps(x,y,p,xx) returns the values s(xx) of this cubic smoothing spline at the given argument sequence xx.

The alternative call csaps(x,y,p) returns instead the ppform of the cubic spline, for later use with fnval, fnder, etc.

It is in general difficult to choose the parameter p without experimentation. For that reason, use of spaps is encouraged since there p is chosen so as to produce the smoothest spline within a specified tolerance of the data.

It is also possible to smooth data on a rectangular grid and obtain smoothed values on a rectangular grid or at scattered points, by the calls

or

in which y is expected to have size [d,length(x1),...,.length(xm)] (or [length(x1),...,.length(xm)] if the function is to be scalar-valued), and p is either a scalar or an m-vector of scalars, and xx is either a list of m-vectors xx(:,j) or else a cell-array {xx1,..., xxm} specifying the m-dimensional grid at which to evaluate the interpolant, and, correspondingly, w, if given, is cell array of weight sequences for the m dimensions (with w{i} empty the indication that the default weights are to be used with the ith variable).

Algorithm

This is an implementation of the Fortran routine SMOOTH from PGS.

See Also

spaps, csape, spap2

Cautionary Note

If the sequence x is not nondecreasing, both x and y will be reordered in concert to make it so.



[ Previous | Help Desk | Next ]