Esc
Ask AIAnswers may be inaccurate; check the linked pages.Esc
Ask anything about these docs, like how to get started or what a function does.

chronax.loess

LOESS/LOWESS (Locally Weighted Scatterplot Smoothing) in JAX. This module implements LOESS (Local Polynomial Regression) with tricube kernel weighting and optional robust reweighting for non-parametric smoothing of time series and scatter data.

loess_window_jump(y, window, deg=1, robust_outer=0, jump=1)

LOESS with fixed odd window using tricube weights. - deg ∈ {0,1}: local constant or local linear (value at center). - robust_outer: bisquare outer reweighting count. - jump: compute only at anchor points and linearly interpolate in-between (STL-like speedup).

Parameter Type Default Description
y jnp.ndarray - Input 1D array to smooth.
window int - Window size (will be forced to odd).
deg int 1 Polynomial degree, 0 (local constant) or 1 (local linear).
robust_outer int 0 Number of robust reweighting iterations using bisquare weights.
jump int 1 Evaluate only at anchor points (0, jump, 2*jump, ...) and interpolate.

Returns: jnp.ndarray (Smoothed values of shape (n,)).

lowess_frac(y, x, frac=2.0 / 3.0, it=0)

Statsmodels-style LOWESS (Cleveland): - Neighborhood defined by frac*n nearest x. - Tricube kernel; robust outer iterations via bisquare. - Returns yhat aligned to x (input order). Note: 'delta' skip optimization is omitted for JAX-purity.

Parameter Type Default Description
y jnp.ndarray - Input 1D array of values to smooth.
x jnp.ndarray - Input 1D array of x-coordinates (arbitrary order).
frac float 2.0 / 3.0 Fraction of data used for neighborhood (0 < frac <= 1).
it int 0 Number of robust reweighting iterations.

Returns: jnp.ndarray (Smoothed values of shape (n,) aligned to input order).

loess_smooth(y, *, window=None, frac=None, deg=1, robust_outer=0, jump=1, x=None)

Convenience wrapper. Choose one mode: - Fixed-window: pass window (odd). Uses loess_window_jump (supports jump, deg, robust_outer). - Frac-based: pass frac and x. Uses lowess_frac (supports robust iterations).

Parameter Type Default Description
y jnp.ndarray - Input 1D array to smooth.
window int | None None Window size for fixed-window LOESS.
frac float | None None Fraction of data for neighborhood in LOWESS mode.
deg int 1 Polynomial degree (0 or 1) for fixed-window mode.
robust_outer int 0 Number of robust reweighting iterations.
jump int 1 Jump size for anchor points in fixed-window mode.
x jnp.ndarray | None None X-coordinates for LOWESS mode.

Returns: jnp.ndarray (Smoothed values of shape (n,)). Raises: ValueError (If neither window nor (frac, x) are provided.)