incline.Smoother¶
- class incline.Smoother[source]¶
Base class for every trend estimator.
Subclasses implement
evaluate()andwith_scale()and declare whether they are linear. Everything else – uncertainty, bias correction, simultaneous bands, result assembly – is inherited.- __init__()¶
Methods
__init__()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)Smooth a series and differentiate the smooth.
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()Smoother-specific settings, recorded on the result.
scale_of(axis)Report this smoother's current scale as a fraction of the span.
with_scale(scale, axis)Return a copy smoothing across
scaleof the series span.Attributes
Whether the derivative is a fixed linear map of the data.
Whether a supplied noise model can change the point estimate.
- property is_linear: bool¶
Whether the derivative is a fixed linear map of the data.
A property rather than the class attribute alone because some smoothers are linear only in certain configurations.
- abstractmethod evaluate(axis, y, derivative_order)[source]¶
Smooth a series and differentiate the smooth.
- evaluate_with_noise(axis, y, derivative_order, noise)[source]¶
Evaluate, allowing an adaptive smoother to use a fitted covariance.
- abstractmethod with_scale(scale, axis)[source]¶
Return a copy smoothing across
scaleof the series span.
- abstractmethod scale_of(axis)[source]¶
Report this smoother’s current scale as a fraction of the span.
- analytic_operators(axis, derivative_order)[source]¶
State the smoothing and derivative operators directly, if known.
A linear smoother’s operators are already implicit in the arithmetic it performs, so a smoother that fits a local system per point can emit its operator rows from the same solve. Doing so turns an O(n) probe into a constant factor. Returning None falls back to probing.
- operators(axis, derivative_order)[source]¶
The smoothing and derivative operators for this configuration.
Cached: an operator depends on the smoother’s settings, the axis and the derivative order, but never on the observed values. Repeated fits over the same grid – a multi-scale sweep, a Monte Carlo study – reuse the work.
- native_posterior(axis, y, derivative_order, confidence_level)[source]¶
Uncertainty from the smoother’s own probability model.
Overridden by smoothers that are probability models and therefore already know their posterior variance.
- Parameters:
- Returns:
Tuple of (se, ci_lower, ci_upper), or None if unsupported.
- Return type:
tuple[npt.NDArray[np.float64], npt.NDArray[np.float64] | None, npt.NDArray[np.float64] | None] | None
- fit(axis, y, derivative_order=1, with_uncertainty=False, noise=None, bias_correct=False, simultaneous=False, confidence_level=0.95, pilot_scale=None, n_bootstrap=200, random_state=None)[source]¶
Estimate the trend and, optionally, its uncertainty.
- Parameters:
axis (TimeAxis) – The time axis.
y (npt.NDArray[np.float64]) – Observed values.
derivative_order (int) – Derivative derivative_order.
with_uncertainty (bool) – Whether to compute standard errors. Off by default because the exact route costs one smoother evaluation per observation.
noise (NoiseModel | str | None) – Noise model instance, or
'iid','ar1'`, or ``'heteroskedastic'.bias_correct (bool) – Subtract an estimate of smoothing bias using a less-smoothed pilot fit. Linear smoothers only.
simultaneous (bool) – Return a band covering the whole curve at once rather than pointwise intervals. Fixed linear smoothers only.
confidence_level (float) – Confidence level for intervals.
pilot_scale (float | None) – Scale of the pilot fit used for bias correction. Defaults to a third of this smoother’s scale.
n_bootstrap (int) – Replicates, for nonlinear smoothers.
random_state (int | np.random.Generator | None) – Seed or Generator.
- Returns:
The estimate.
- Raises:
ValueError – If an argument is outside its domain, the derivative derivative_order is unsupported, bias correction is requested for a nonlinear smoother, or an uncertainty option is incompatible with a native posterior.
- Return type:
- bootstrap_uncertainty(estimate, axis, y, derivative_order, noise_model, noise_fit, confidence_level, n_bootstrap, random_state)[source]¶
Bootstrap a nonlinear smoother, preserving short-range dependence.
- Parameters:
estimate (TrendEstimate) – Original fitted result.
axis (TimeAxis) – Time axis.
y (npt.NDArray[np.float64]) – Observed values.
derivative_order (int) – Derivative order.
noise_model (NoiseModel) – Noise model specification.
noise_fit (NoiseFit) – Fitted noise covariance.
confidence_level (float) – Confidence level.
n_bootstrap (int) – Number of replicates.
random_state (int | np.random.Generator | None) – Seed or Generator.
- Returns:
Standard errors and percentile interval bounds.
- Return type:
tuple[npt.NDArray[np.float64] | None, npt.NDArray[np.float64] | None, npt.NDArray[np.float64] | None]