Expand description
Smoothing splines with automatically placed knots, after Dierckx’s FITPACK (curfit and
parcur), following SciPy’s make_splrep, make_splprep and generate_knots.
Given data (xᵢ, yᵢ), weights wᵢ and a smoothing factor s, the spline g of degree k
is the smoothest one — the sum of squared jumps of g⁽ᵏ⁾ at its interior knots is least —
among those with Σ (wᵢ (yᵢ − g(xᵢ)))² ≤ s. The knots are found by adding them one interval
at a time where the least-squares spline fits worst, until the least-squares fit is within
s; then the weight p of the data against smoothness is found by rational interpolation so
that the residual equals s.
See the book entry Smoothing splines with automatic knots.
Structs§
- Splrep
Info - The result of
make_splrepandmake_splprepbeyond the spline itself. - Splrep
Options - Options for
make_splrep,make_splprepandgenerate_knots(SciPy’s keyword arguments; the defaults are SciPy’s).
Functions§
- generate_
knots - The successive knot vectors FITPACK tries (SciPy’s
generate_knots): from the2(k + 1)knots of a polynomial, knots are added where the least-squares spline fits worst —1, 2, 4, …per round, fewer as the residual nearss— until the least-squares residual is at mosts, the limitnestis reached, or the knots become those of the interpolating spline. The last vector is the onemake_splrepuses. - make_
splprep - A smoothing parametric spline curve through
points(one row per point, one column per coordinate) with shared, automatically placed knots (SciPy’smake_splprep, FITPACK’sparcur). The parameterudefaults to the cumulative chord length scaled to[0, 1]; the smoothing criterion sums the squared residuals over all coordinates. Returnsuand one spline per coordinate, all on the same knots. - make_
splrep - The smoothing spline of degree
kwith automatically placed knots (SciPy’smake_splrep, FITPACK’scurfit): of all splines withΣ (wᵢ (yᵢ − g(xᵢ)))² ≤ s, the one whosek-th derivative jumps least at its interior knots.s = 0gives the interpolating spline with not-a-knot ends; a largesgives the least-squares polynomial. With weights1/σᵢ, a goodslies inm ± √(2m).tfixes the knots instead of generating them. - make_
splrep_ periodic - The periodic smoothing spline with automatically placed knots (SciPy’s
make_splrep(..., bc_type='periodic'), FITPACK’spercur): the spline and its firstk − 1derivatives match atxbandxe = xb + period, the last data point stands for the first one shifted by a period, and otherwise the criterion ismake_splrep’s. The free coefficients are the firstn − 2k − 1; the lastkrepeat them.