{ } Raw JSON

bundles / scipy latest / scipy / interpolate / _fitpack_repro / Fperiodic

class

scipy.interpolate._fitpack_repro:Fperiodic

source: /scipy/interpolate/_fitpack_repro.py :610

Signature

class   Fperiodic ( x y t k s w = None * R = None Y = None A1 = None A2 = None Z = None )

Members

Summary

Fit a smooth periodic B-spline curve to given data points.

Extended Summary

This class fits a periodic B-spline curve S(t) of degree k through data points (x, y) with knots t. The spline is smooth and repeats itself at the start and end, meaning the function and its derivatives up to order k-1 are equal at the boundaries.

We want to find spline coefficients c that minimize the difference between the spline and the data, while also keeping the spline smooth. This is done by solving:

minimize || W^{1/2} (Y - B c) ||^2 + s * c^T @ R @ c subject to periodic constraints on c.

where:

  • Y is the data values,

  • B is the matrix of B-spline basis functions at points x,

  • W is a weighting matrix for the data points,

  • s is the smoothing parameter (larger s means smoother curve),

  • R is a matrix that penalizes wiggliness of the spline,

  • c spline coefficients to be solved for

  • periodic constraints ensure the spline repeats smoothly.

The solution is obtained by forming augmented matrices and performing a QR factorization that incorporates these constraints, following the approach in FITPACK's fpperi.f.

Parameters

x : array_like, shape (n,)
y : array_like, shape (n, m)
t : array_like, shape (nt,)

Knot vector for the spline

k : int

Degree of the spline.

s : float

Controls smoothness: bigger s means smoother curve, smaller s fits data closer.

w : array_like, shape (n,), optional

Weights for data points. Defaults to all ones.

R, Y, A1, A2, Z : arrays, optional

Precomputed matrices from least squares and QR factorization steps to speed up repeated fits with the same knots and data.

Attributes

G1, G2 : arrays

Augmented matrices combining the original QR factors and constraints related to the spline basis and data. G1 is roughly the "upper-triangular" part; G2 contains additional constraint information for periodicity.

H1, H2 : arrays

Matrices associated with the discontinuity jump constraints of the k-th derivative of B-splines at the knots. These encode the periodicity conditions and are scaled by the smoothing parameter.

offset : array

Offset indices used for efficient indexing during QR reduction.

Methods

__call__(p):

Perform QR reduction of augmented matrices scaled by 1/p, solve for spline coefficients, and return residual difference fp - s.

Aliases

  • scipy.interpolate._fitpack_repro.Fperiodic