incline.LocalPolynomial

class incline.LocalPolynomial(bandwidth=0.2, degree=2, kernel='gaussian')[source]

Local polynomial regression with kernel weights.

Fits a weighted least squares polynomial around every point and reads the derivative off the coefficients.

Variables:
  • bandwidth (float) – Kernel width as a fraction of the series span.

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

  • kernel (str) – 'gaussian', 'epanechnikov' or 'uniform'.

Parameters:
__init__(bandwidth=0.2, degree=2, kernel='gaussian')
Parameters:
Return type:

None

Methods

__init__([bandwidth, degree, kernel])

analytic_operators(axis, order)

Emit the operator rows from the same weighted least squares solve.

evaluate(axis, y, order)

Fit a weighted local polynomial at every point.

fit(axis, y[, order, se, noise, ...])

Estimate the trend and, optionally, its uncertainty.

native_posterior(axis, y, order, ...)

Uncertainty from the smoother's own probability model.

operators(axis, order)

The smoothing and derivative operators for this configuration.

params()

Report bandwidth, degree and kernel.

scale_of(axis)

Bandwidth as a fraction of the span.

with_scale(scale, axis)

Set the kernel bandwidth to scale of the span.

Attributes

bandwidth

degree

has_native_posterior

is_linear

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

kernel

linear

name

requires_regular_grid

supported_orders

name: ClassVar[str] = 'local_poly'
linear: ClassVar[bool] = True
bandwidth: float = 0.2
degree: int = 2
kernel: str = 'gaussian'
evaluate(axis, y, order)[source]

Fit a weighted local polynomial at every point.

Parameters:
  • axis (TimeAxis)

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

  • order (int)

Return type:

Evaluation

analytic_operators(axis, order)[source]

Emit the operator rows from the same weighted least squares solve.

Each point’s estimate is e_k' (X'WX)^-1 X'W y; the row vector in front of y is that point’s operator row. Building it costs one extra solve against an identity block rather than n full evaluations.

Parameters:
Return type:

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

with_scale(scale, axis)[source]

Set the kernel bandwidth to scale of the span.

Parameters:
Return type:

Self

scale_of(axis)[source]

Bandwidth as a fraction of the span.

Parameters:

axis (TimeAxis)

Return type:

float

params()[source]

Report bandwidth, degree and kernel.

Return type:

dict[str, Any]