Function File: [yi p sigma2 unc_yi df] = csaps(x, y, p=[], xi=[], w=[])
Function File: [pp p sigma2] = csaps(x, y, p=[], [], w=[])

Cubic spline approximation (smoothing)
approximate [x,y], weighted by w (inverse variance of the y values; if not given, equal weighting is assumed), at xi

The chosen cubic spline with natural boundary conditions pp(x) minimizes p * Sum_i w_i*(y_i - pp(x_i))^2 + (1-p) * Int pp”(x) dx

Outside the range of x, the cubic spline is a straight line

x and w should be n by 1 in size; y should be n by m; xi should be k by 1; the values in x should be distinct and in ascending order; the values in w should be nonzero

p should be a scalar or empty:

p=0

maximum smoothing: straight line

p=1

no smoothing: interpolation

p<0 or empty

an intermediate amount of smoothing is chosen
and the corresponding p between 0 and 1 is returned
(such that the smoothing term and the interpolation term are of the same magnitude)
(csaps_sel provides other methods for automatically selecting the smoothing parameter p.)

sigma2 is an estimate of the data error variance, assuming the smoothing parameter p is realistic

unc_yi is an estimate of the standard error of the fitted curve(s) at the xi. Empty if xi is not provided.

df is an estimate of the degrees of freedom used in the spline fit (2 for p=0, n for p=1)

References:
Carl de Boor (1978), A Practical Guide to Splines, Springer, Chapter XIV
Grace Wahba (1983), Bayesian “confidence intervals” for the cross-validated smoothing spline, Journal of the Royal Statistical Society, 45B(1):133-150

See also: spline, splinefit, csapi, ppval, dedup, bin_values, csaps_sel.

Package: splines