incline.SavitzkyGolay

class incline.SavitzkyGolay(window_length=15, degree=3)[source]

Savitzky-Golay filter: local polynomial least squares on a fixed window.

A fixed convolution, so the derivative operator is available in closed form as well as by probing – the two agree to 1e-15, which makes this the natural cross-check on the probe machinery.

Variables:
  • window_length (int) – Odd number of points in the window.

  • degree (int) – Degree of the local polynomial.

Parameters:
  • window_length (int)

  • degree (int)

__init__(window_length=15, degree=3)
Parameters:
  • window_length (int)

  • degree (int)

Return type:

None

Methods

__init__([window_length, degree])

analytic_operators(axis, derivative_order)

State the smoothing and derivative operators directly, if known.

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

Bootstrap a nonlinear smoother, preserving short-range dependence.

closed_form_se(axis, derivative_order, ...)

Interior standard error from the filter coefficients directly.

evaluate(axis, y, derivative_order)

Filter the series and differentiate.

evaluate_with_noise(axis, y, ...)

Evaluate, allowing an adaptive smoother to use a fitted covariance.

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 window and polynomial degree.

scale_of(axis)

Window length as a fraction of the sample.

with_scale(scale, axis)

Set the window to scale of the sample.

Attributes

degree

has_native_posterior

is_linear

Whether the derivative is a fixed linear map of the data.

linear

name

requires_regular_grid

supported_orders

uses_noise_for_fit

Whether a supplied noise model can change the point estimate.

window_length

name: ClassVar[str] = 'sgolay'
linear: ClassVar[bool] = True
supported_orders: ClassVar[frozenset[int]] = frozenset({0, 1, 2, 3})
requires_regular_grid: ClassVar[bool] = True
window_length: int = 15
degree: int = 3
evaluate(axis, y, derivative_order)[source]

Filter the series and differentiate.

Parameters:
  • axis (TimeAxis)

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

  • derivative_order (int)

Return type:

Evaluation

closed_form_se(axis, derivative_order, standard_deviation)[source]

Interior standard error from the filter coefficients directly.

Parameters:
  • axis (TimeAxis) – The time axis.

  • derivative_order (int) – Derivative derivative_order.

  • standard_deviation (float) – Noise standard deviation.

Returns:

The constant interior standard error, broadcast over the series.

Return type:

npt.NDArray[np.float64]

with_scale(scale, axis)[source]

Set the window to scale of the sample.

Parameters:
Return type:

Self

scale_of(axis)[source]

Window length as a fraction of the sample.

Parameters:

axis (TimeAxis)

Return type:

float

params()[source]

Report the window and polynomial degree.

Return type:

dict[str, Any]