Ten Little Algorithms, Part 3: Welford's Method (and Friends)
Other articles in this series: Part 1: Russian Peasant Multiplication Part 2: The Single-Pole Low-Pass Filter Last time we talked about a low-pass filter, and we saw that a one-line algorithm could filter out high-frequency noise, and...
Summary
Jason Sachs explains Welford's online algorithm for computing mean and variance in a numerically stable way, and surveys related streaming-statistics techniques suited to resource-constrained systems. The article includes implementation notes, numerical/overflow considerations (floating- and fixed-point), and practical uses such as sensor calibration, anomaly detection, and merging partial statistics in embedded/IoT firmware.
Key Takeaways
- Implement Welford's online algorithm to compute running mean and variance with numerical stability.
- Avoid precision loss and overflow by using stable update formulas and pairwise combining of statistics.
- Adapt algorithms for constrained devices by applying fixed-point techniques and low-memory implementation patterns.
- Merge partial statistics from multiple threads or nodes using pairwise/aggregate formulas for distributed systems.
- Apply the methods to real embedded use cases such as sensor calibration, anomaly detection, and summary telemetry.
Who Should Read This
Intermediate embedded/IoT firmware engineers and developers who process streaming sensor data on microcontrollers and need reliable, low-overhead statistical summaries for calibration, diagnostics, or telemetry.
TimelessIntermediate
Related Documents
- Consistent Overhead Byte Stuffing TimelessIntermediate
- PID Without a PhD TimelessIntermediate
- Introduction to Embedded Systems - A Cyber-Physical Systems Approach Still RelevantIntermediate
- Can an RTOS be really real-time? TimelessAdvanced
- Memory Mapped I/O in C TimelessIntermediate








