packages

interpolate::smooth::lowess

LOWESS, locally weighted scatterplot smoothing (Cleveland 1979): at each x, the weighted least-squares line through the nearest frac * n points with tricube weights; then iters robustness passes that reweight by the bisquare of the residuals over six median absolute residuals. O(iters n k) for k = frac n neighbours, less with delta.

Functions

lowessSource

pub fn lowess<X: AsVector<f64>, Y: AsVector<f64>>(x: X, y: Y, frac: f64 = 0.6666666666666666, iters: usize = 3, delta: f64 = 0.0) throws (InterpError) -> Vector<f64>

The LOWESS fit of y on x at every x, in input order (x need not be sorted). frac is the share of points in each local fit (at least 2 points), iters the robustness passes (0 for the plain local fit), and delta skips the fit at points within delta of the last one fitted, interpolating linearly there instead (0 fits every point; about 1% of the x range is a good speed-up for large n).

nabi
let y = try interpolate::lowess([0, 1, 2, 3, 4, 5], [1, 3, 5, 7, 9, 11]);
assert((y[2] - 5.0).abs() < 1e-12);