Hasty Briefsbeta

Bilingual

Recursive Filters: SMA, EMA, Low‑Pass, and a Tiny Kalman

2 days ago
  • Recursive filters are ideal when compute and memory are limited, data streams in, and immediate response is needed.
  • They require O(1) memory and O(1) compute per sample, making them suitable for microcontrollers and real-time systems.
  • The EMA (Exponential Moving Average) is a simple leaky integrator with a smoothing factor alpha, where higher alpha means smoother output but more lag.
  • SMA (Simple Moving Average) averages the last N samples, effectively reducing noise but introducing lag and requiring a buffer.
  • A first-order low-pass filter is mathematically equivalent to an EMA, with the parameter alpha controlling the trade-off between noise suppression and responsiveness.
  • A tiny 1D Kalman filter provides adaptive gain by balancing trust between prediction and measurement based on sensor and process noise.
  • Parameter choices: SMA window N for smoothness versus lag, EMA alpha around 0.1–0.3, Kalman R for sensor noise and Q for process drift.
  • SMA is robust, EMA is the default for streaming, and a 1D Kalman adds principled adaptivity when noise estimates are available.