Curve Fitting Toolbox | ![]() ![]() |
Smoothing Spline
If your data is noisy, you might want to fit it using a smoothing spline. Alternatively, you can use one of the smoothing methods described in Smoothing Data.
The smoothing spline s is constructed for the specified smoothing parameter p and the specified weights wi. The smoothing spline minimizes
If the weights are not specified, they are assumed to be 1 for all data points.
p is defined between 0 and 1. p = 0 produces a least squares straight line fit to the data, while p = 1 produces a cubic spline interpolant. If you do not specify the smoothing parameter, it is automatically selected in the "interesting range." The interesting range of p is often near 1/(1+h3/6) where h is the average spacing of the data points, and it is typically much smaller than the allowed range of the parameter. Because smoothing splines have an associated parameter, you can consider these fits to be parametric. However, smoothing splines are also piecewise polynomials like cubic spline or shape-preserving interpolants and are considered a nonparametric fit type in this guide.
Note
The smoothing spline algorithm used by the Curve Fitting Toolbox is based on the csaps function included with the Spline Toolbox. Refer to the csaps reference pages for detailed information about smoothing splines.
|
The nuclear reaction data from the file carbon12alpha.mat
is shown below with three smoothing spline fits. The default smoothing parameter (p = 0.99) produces the smoothest curve. The cubic spline curve (p = 1) goes through all the data points, but is not quite as smooth. The third curve (p = 0.95) misses the data by wide margin and illustrates how small the "interesting range" of p can be.
![]() | Interpolants | Example: Nonparametric Fit | ![]() |