Skip to main content

Module fitpack

Module fitpack 

Source
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§

SplrepInfo
The result of make_splrep and make_splprep beyond the spline itself.
SplrepOptions
Options for make_splrep, make_splprep and generate_knots (SciPy’s keyword arguments; the defaults are SciPy’s).

Functions§

generate_knots
The successive knot vectors FITPACK tries (SciPy’s generate_knots): from the 2(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 nears s — until the least-squares residual is at most s, the limit nest is reached, or the knots become those of the interpolating spline. The last vector is the one make_splrep uses.
make_splprep
A smoothing parametric spline curve through points (one row per point, one column per coordinate) with shared, automatically placed knots (SciPy’s make_splprep, FITPACK’s parcur). The parameter u defaults to the cumulative chord length scaled to [0, 1]; the smoothing criterion sums the squared residuals over all coordinates. Returns u and one spline per coordinate, all on the same knots.
make_splrep
The smoothing spline of degree k with automatically placed knots (SciPy’s make_splrep, FITPACK’s curfit): of all splines with Σ (wᵢ (yᵢ − g(xᵢ)))² ≤ s, the one whose k-th derivative jumps least at its interior knots. s = 0 gives the interpolating spline with not-a-knot ends; a large s gives the least-squares polynomial. With weights 1/σᵢ, a good s lies in m ± √(2m). t fixes 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’s percur): the spline and its first k − 1 derivatives match at xb and xe = xb + period, the last data point stands for the first one shifted by a period, and otherwise the criterion is make_splrep’s. The free coefficients are the first n − 2k − 1; the last k repeat them.