While exploring optimizers I fell down the rabbit hole of recursive filters. This post is a compact, practical tour of smoothers you can use when measurements are noisy but latency and compute are tight. We’ll keep the math minimal, the intuition high, and focus on when and why to use SMA, EMA/low‑pass, and a tiny 1D Kalman.
If you are here just for code, my Kaggle Notebook can be found here.
Why recursive filters
Recursive filters shine when compute and memory are scarce, or when data arrives as a stream and you must react immediately.
O(1) memory : you keep just the last state (and maybe a running sum) rather than a long buffer.
: you keep just the last state (and maybe a running sum) rather than a long buffer. O(1) compute per sample : one or two multiply‑adds per step—perfect for microcontrollers and tight loops.
: one or two multiply‑adds per step—perfect for microcontrollers and tight loops. Online, low‑latency : produce an updated estimate as soon as a sample arrives; no need to wait for a full window.
: produce an updated estimate as soon as a sample arrives; no need to wait for a full window. Simple, robust implementations : easy to port, vectorize, or run in reduced precision.
: easy to port, vectorize, or run in reduced precision. Graceful with irregular sampling: updates are incremental and don’t assume batch availability.
Intuition note Recursive filters that we’ll use, all use constant‑size state. That’s why they’re common in embedded systems, robotics control loops, mobile sensor smoothing and telemetry.
... continue reading