Skip to content

OnlineLowess API

See also: fastLowess

  • Data arrives incrementally (sensors, streams)
  • Need real-time smoothed values
  • Fixed memory budget

Online Adapter

The OnlineLowess class updates the model incrementally with new data points.

Constructor:

const { OnlineLowess } = require('fastlowess-wasm');
const online = new OnlineLowess({ fraction: 0.5 }, { window_capacity: 50, min_points: 3 });
console.log("typeof add_point:", typeof online.add_point);
typeof add_point: function
  • options: An object containing LowessOptions fields.
  • onlineOptions: An object containing OnlineOptions fields.

Methods:

const { OnlineLowess } = require('fastlowess-wasm');
const n = 100;
const x = Float64Array.from({ length: n }, (_, i) => i * 2 * Math.PI / (n - 1));
const y = Float64Array.from(x, xi => Math.sin(xi) + 0.1);
const online = new OnlineLowess({ fraction: 0.5 }, { window_capacity: 50, min_points: 3 });
// Returns null until min_points (3) are reached
online.add_point(x[0], y[0]); // null
online.add_point(x[1], y[1]); // null
// Returns OnlineOutput once enough points are available
const result = online.add_point(x[2], y[2]);
console.log("Smoothed y:", result.y);
Smoothed y: 0.22659245357374927
  • Adds a single point to the sliding window. Returns an OnlineOutput once enough points are available, or null while the window is still filling.
Field Type Default Description
window_capacity number 1000 Max points in sliding window
min_points number 2 Min points before smoothing starts
update_mode string "incremental" Update mode ("full" or "incremental")
parallel boolean false Enable parallel execution (off by default; online LOWESS fits one point at a time)

Returned by add_point() once the window has enough points (null until then).

Field Type Description
y number Smoothed value for the latest point
standard_error number | undefined Standard error (if requested)
residual number | undefined Residual y − smoothed (if requested)
robustness_weight number | undefined Robustness weight (if requested)
iterations_used number | undefined Robustness iterations performed

See: Execution Modes

Mode Alias Behavior Speed
"incremental" (default) "single" Update only affected fits Faster
"full" "resmooth" Recompute entire window More accurate