incline.L1TrendFilter

class incline.L1TrendFilter(penalty=None, penalty_fraction=None, difference_order=2, max_iter=1000, tolerance=1e-08)[source]

L1 trend filtering: piecewise-polynomial fit with sparse kinks.

This implements the estimator of Kim et al. (2009), https://doi.org/10.1137/070690274, and its arbitrary-input extension from Tibshirani (2014), https://doi.org/10.1214/13-AOS1189. The convex problem is solved through its box-constrained least-squares dual using SciPy’s lsq_linear; Incline constructs the grid-aware penalty operator and maps the dual solution back to the fitted trend.

The L1 penalty is nonlinear in the data – that is what produces sparse kinks – so uncertainty is bootstrapped.

The penalized difference order and the reported derivative order are separate settings; the previous implementation used one for both.

Variables:
  • penalty (float | None) – Absolute penalty on the differences. Larger means fewer kinks. Exactly one of penalty and penalty_fraction is required.

  • penalty_fraction (float | None) – Fraction of the smallest penalty that collapses the fit to a polynomial of degree difference_order - 1. Exactly one of penalty and penalty_fraction is required.

  • difference_order (int) – Order of the penalized difference. Two gives a piecewise-linear trend, the usual choice.

  • max_iter (int) – Bounded least-squares iteration cap.

  • tolerance (float) – Optimizer convergence tolerance.

Parameters:
  • penalty (float | None)

  • penalty_fraction (float | None)

  • difference_order (int)

  • max_iter (int)

  • tolerance (float)

__init__(penalty=None, penalty_fraction=None, difference_order=2, max_iter=1000, tolerance=1e-08)
Parameters:
  • penalty (float | None)

  • penalty_fraction (float | None)

  • difference_order (int)

  • max_iter (int)

  • tolerance (float)

Return type:

None

Methods

__init__([penalty, penalty_fraction, ...])

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.

evaluate(axis, y, derivative_order)

Solve the L1 trend filtering problem, then difference the fit.

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 configured penalty and optimizer settings.

scale_of(axis)

Return the configured relative scale when one exists.

with_scale(scale, axis)

Set the penalty as a fraction of its saturating value.

Attributes

difference_order

has_native_posterior

is_linear

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

linear

max_iter

name

penalty

penalty_fraction

requires_regular_grid

supported_orders

tolerance

uses_noise_for_fit

Whether a supplied noise model can change the point estimate.

name: ClassVar[str] = 'l1_filter'
penalty: float | None = None
penalty_fraction: float | None = None
difference_order: int = 2
max_iter: int = 1000
tolerance: float = 1e-08
evaluate(axis, y, derivative_order)[source]

Solve the L1 trend filtering problem, then difference the fit.

Parameters:
  • axis (TimeAxis)

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

  • derivative_order (int)

Return type:

Evaluation

with_scale(scale, axis)[source]

Set the penalty as a fraction of its saturating value.

Parameters:
Return type:

Self

scale_of(axis)[source]

Return the configured relative scale when one exists.

Parameters:

axis (TimeAxis)

Return type:

float | None

params()[source]

Report the configured penalty and optimizer settings.

Return type:

dict[str, Any]