Skip to Content

Explore · intelligence

Kalman 1D filter

A Kalman filter keeps a running estimate of a noisy signal. Each tick it predicts what it expects next, then corrects using the actual measurement. The difference — called the innovation — is the diagnostic signal: small means the model matches reality, large means something changed.

Smoothing and Outlier Detection

The signal below is a noisy sensor reading with a few sudden spikes and a step change partway through. The filter smooths the noise while the innovation gate flags samples that are too far from what it predicted.

Parameters — drag the sliders and watch the chart respond:

  • processVariance — the filter’s assumption about how much the real signal drifts per tick. Raise it and the filter trusts each new measurement more (responsive). Lower it and the filter trusts its own prediction more (smooth).
  • sensorVariance — how noisy you believe the sensor is. Raise it and the filter discounts measurements — it leans on the model instead. Set it to your sensor’s measured noise variance (σ²).
  • chi2Threshold — how large the prediction error must be before flagging an outlier. 3.84 = 5% false alarm rate, 6.63 = 1%, 10.83 = 0.1%.
  • followMode — Exclude rejects the outlier and continues from the prediction. Follow resets to the measurement — use this for real step changes, not sensor faults.
Loading kalman 1d explorer...

Try this:

  • Set chi2Threshold low (~3) and watch false alarms multiply.
  • Switch followMode to Follow and see the filter track the step change at sample 200 instantly instead of slowly converging.
  • Drag processVariance to 2 — the filter follows every wiggle. Then drag it to 0.001 — it barely moves.

Adding a Known Input

The demo above treats the filter as a smoother — it has no idea why the signal changes. But when you tell the filter about a known influence on the signal, it becomes a diagnostic tool: the innovation stops reflecting noise and starts reflecting what the model cannot explain.

You provide the filter with a second input — a known cause like discharge current, fuel flow, or motor speed — and a scaling factor (controlModel) that converts that input into the expected change per tick. Each tick the filter predicts: given this much current, the charge should drop by this much. Then it corrects with the actual measurement. When prediction and measurement agree, innovation hovers near zero. When they disagree persistently, something the sensor cannot see is affecting the system.

Different faults produce different innovation signatures — parasitic drain drifts negative, capacity fade drifts negative under load, sensor drift flips positive. The direction and pattern identify the root cause.

See Hidden Parasitic Drain for an interactive recipe that uses this pattern to diagnose a parasitic battery drain — with a full pipeline you can grab and adapt.


kalman1d Quick Reference

Parameters exposed as sliders on this page:

ParameterDefaultWhat it controls
processVariance0.01How much the signal can drift per tick beyond the model. Higher = responsive, lower = smooth.
sensorVariance1Sensor noise variance. Set to your sensor’s measured σ².
chi2Threshold6.63Innovation gate. 3.84 = 5% false alarms, 6.63 = 1%, 10.83 = 0.1%.
followModefalsefalse = reject outliers. true = track step changes.

For the full parameter reference including controlModel, stateTransition, and measurement, see the nodes reference.


References

  • R. E. Kalman, “A New Approach to Linear Filtering and Prediction Problems,” Journal of Basic Engineering, 82(1), pp. 35—45, 1960. doi:10.1115/1.3662552 

Next Steps

  • Hidden Parasitic Drain — a complete recipe that uses kalman1d control input to detect parasitic drain in a battery system
  • Sudden Shifts — detect step changes using kalman1d with innovation gating
  • Under the Hood — how messages flow through a Composer pipeline at runtime
Last updated on