>  Docs Center  >  IDL Reference  >  Advanced Math and Stats  >  IMSL_CSSMOOTH

IMSL_CSSMOOTH

IMSL_CSSMOOTH

The CSSMOOTH function computes a smooth cubic spline approximation to noisy data by using cross-validation to estimate the smoothing parameter or by directly choosing the smoothing parameter.

This routine requires an IDL Advanced Math and Stats license. For more information, contact your sales or technical support representative.

The IMSL_CSSMOOTH function is designed to produce a C2 cubic spline approximation to a data set in which the function values are noisy. This spline is called a smoothing spline.

Consider first the situation when the optional keyword SMPAR is selected. Then, a natural cubic spline with knots at all the data abscissas x = Xdata is computed, but it does not interpolate the data (xi, fi). The smoothing spline s is the unique C2 function which minimizes:

subject to the constraint:

where w = WEIGHTS, σ = SMPAR is the smoothing parameter, and n = N_ELEMENTS(Xdata).

Recommended values for σ depend on the weights w. If an estimate for the standard deviation of the error in the value fi is available, then wi should be set to the inverse of this value. The smoothing parameter σ should be chosen in the confidence interval corresponding to the left side of the above inequality; that is:

The IMSL_CSSMOOTH function is based on an algorithm of Reinsch (1967). This algorithm also is discussed in de Boor (1978, pp. 235–243).

The default for this function chooses the smoothing parameter σ by a statistical technique called cross-validation. For more information on this topic, refer to Craven and Wahba (1979).

The return value for this function is a structure containing all the information to determine the spline (stored as a piecewise polynomial) that is computed by this procedure.

Example


In this example, function values are contaminated by adding a small "random" amount to the correct values. The IMSL_CSSMOOTH function is used to approximate the original, uncontaminated data as shown in the figure below.

n = 25
x = 6 * FINDGEN(n)/(n - 1)
f = SIN(x) + .5 * (IMSL_RANDOM(n) - .5)
 
; Generate the data.
pp = IMSL_CSSMOOTH(x, f)
 
; Compute the fit.
x2 = 6 * FINDGEN(100)/99
; Evaluate the computed fit at 100 values in [0, 6].
ppeval = IMSL_SPVALUE(x2, pp)
PLOT, x2, ppeval
 
; Plot the results.
OPLOT, x, f, Psym = 6, Symsize = .5

Errors


Warning Errors

MATH_MAX_ITERATIONS_REACHED: Maximum number of iterations has been reached. The best approximation is returned.

Fatal Errors

MATH_DUPLICATE_XDATA_VALUES: The xdata values must be distinct.

MATH_NEGATIVE_WEIGHTS: All weights must be greater than or equal to zero.

Syntax


Result = IMSL_CSSMOOTH(Xdata, Fdata [, /DOUBLE] [, SMPAR=value] [, WEIGHTS=value])

Return Value


The structure that represents the cubic spline.

Arguments


Xdata

One-dimensional array containing the abscissas of the problem.

Fdata

One-dimensional array containing the ordinates of the problem.

Keywords


DOUBLE (optional)

If present and nonzero, double precision is used.

SMPAR (optional)

Specifies the real, scalar smoothing parameter explicitly. See the description for more details.

WEIGHTS (optional)

Array containing the weights to be used in the problem. Default: all weights are equal to 1.

Version History


6.4

Introduced



© 2019 Harris Geospatial Solutions, Inc. |  Legal
My Account    |    Store    |    Contact Us