OnlineLowess API
See also: fastLowess
When to Use
Section titled “When to Use”- Data arrives incrementally (sensors, streams)
- Need real-time smoothed values
- Fixed memory budget
OnlineLowess
Section titled “OnlineLowess”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: functionoptions: An object containingLowessOptionsfields.onlineOptions: An object containingOnlineOptionsfields.
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 reachedonline.add_point(x[0], y[0]); // nullonline.add_point(x[1], y[1]); // null
// Returns OnlineOutput once enough points are availableconst 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
OnlineOutputonce enough points are available, ornullwhile the window is still filling.
Options Structure
Section titled “Options Structure”OnlineOptions (inherits LowessOptions)
Section titled “OnlineOptions (inherits LowessOptions)”| 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) |
Result Structure
Section titled “Result Structure”OnlineOutput
Section titled “OnlineOutput”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 |
Options
Section titled “Options”update_mode
Section titled “update_mode”See: Execution Modes
| Mode | Alias | Behavior | Speed |
|---|---|---|---|
"incremental" (default) |
"single" |
Update only affected fits | Faster |
"full" |
"resmooth" |
Recompute entire window | More accurate |