incline.SmoothingSpline

class incline.SmoothingSpline(penalty=None)[source]

Cubic smoothing spline with a second-derivative roughness penalty.

With independent errors this wraps scipy.interpolate.make_smoothing_spline(), SciPy’s implementation of Woltring’s generalized cross-validation algorithm. With a non-diagonal or heteroskedastic covariance it selects the penalty by generalized maximum likelihood and solves the corresponding penalized generalized least-squares problem. A fixed penalty makes the smoother linear; selecting it from the data makes the fit nonlinear.

Variables:

penalty (float | None) – Roughness penalty. Chosen by generalized cross-validation when None – which makes the fit data-dependent and therefore nonlinear.

Parameters:

penalty (float | None)

Note

The GCV algorithm is due to Herman J. Woltring (1986), https://doi.org/10.1016/0141-1195(86)90098-7. The correlated-error penalized-GLS and GML formulation follows Diggle and Hutchinson (1989), https://doi.org/10.1111/j.1467-842X.1989.tb00510.x, and Wang (1998), https://doi.org/10.1080/01621459.1998.10474115. Incline selects the penalty conditional on the fitted NoiseModel; it does not jointly optimize the covariance and penalty. The independent fit and analytic differentiation delegate to scipy.interpolate.make_smoothing_spline(). The GML fit reports a generalized_penalty in its provenance. That value belongs to the covariance-weighted objective and is not interchangeable with the public penalty argument used by the independent-error fit.

__init__(penalty=None)
Parameters:

penalty (float | None)

Return type:

None

Methods

__init__([penalty])

analytic_operators(axis, derivative_order)

State the smoothing and derivative operators directly, if known.

bootstrap_uncertainty(estimate, axis, y, ...)

Repeat covariance fitting and GML selection in every Gaussian draw.

evaluate(axis, y, derivative_order)

Fit the smoothing spline and differentiate it.

evaluate_with_noise(axis, y, ...)

Use covariance-aware GML when an adaptive fit has dependent errors.

fit(axis, y[, derivative_order, ...])

Estimate the trend and, optionally, its uncertainty.

native_posterior(axis, y, derivative_order, ...)

Uncertainty from the smoother's own probability model.

operators(axis, derivative_order)

The smoothing and derivative operators for this configuration.

params()

Report the penalty.

scale_of(axis)

Invert the bandwidth-to-penalty map.

with_scale(scale, axis)

Set the penalty from an equivalent bandwidth.

Attributes

has_native_posterior

is_linear

Linear when the penalty is fixed, not cross-validated.

linear

name

penalty

requires_regular_grid

supported_orders

uses_noise_for_fit

Adaptive selection uses covariance; a fixed penalty does not.

name: ClassVar[str] = 'smoothing_spline'
supported_orders: ClassVar[frozenset[int]] = frozenset({0, 1, 2, 3})
penalty: float | None = None
property is_linear: bool

Linear when the penalty is fixed, not cross-validated.

property uses_noise_for_fit: bool

Adaptive selection uses covariance; a fixed penalty does not.

evaluate(axis, y, derivative_order)[source]

Fit the smoothing spline and differentiate it.

Parameters:
  • axis (TimeAxis)

  • y (npt.NDArray[np.float64])

  • derivative_order (int)

Return type:

Evaluation

evaluate_with_noise(axis, y, derivative_order, noise)[source]

Use covariance-aware GML when an adaptive fit has dependent errors.

Parameters:
  • axis (TimeAxis)

  • y (npt.NDArray[np.float64])

  • derivative_order (int)

  • noise (NoiseFit | None)

Return type:

Evaluation

bootstrap_uncertainty(estimate, axis, y, derivative_order, noise_model, noise_fit, confidence_level, n_bootstrap, random_state)[source]

Repeat covariance fitting and GML selection in every Gaussian draw.

Parameters:
  • estimate (TrendEstimate)

  • axis (TimeAxis)

  • y (npt.NDArray[np.float64])

  • derivative_order (int)

  • noise_model (NoiseModel)

  • noise_fit (NoiseFit)

  • confidence_level (float)

  • n_bootstrap (int)

  • random_state (int | np.random.Generator | None)

Return type:

tuple[npt.NDArray[np.float64] | None, npt.NDArray[np.float64] | None, npt.NDArray[np.float64] | None]

with_scale(scale, axis)[source]

Set the penalty from an equivalent bandwidth.

For a cubic smoothing spline the equivalent kernel width behaves like (penalty / n) ** (1/4), so a target width of scale * span implies penalty = n * (scale * span) ** 4.

Parameters:
Return type:

Self

scale_of(axis)[source]

Invert the bandwidth-to-penalty map.

Parameters:

axis (TimeAxis)

Return type:

float | None

params()[source]

Report the penalty.

Return type:

dict[str, Any]