Welford's method
A way to keep a running mean and variance, one value at a time, without big sums that lose precision.
Welford's method updates n, the mean μ and M2 for each value x by δ = x - μ, μ += δ/n, M2 += δ(x - μ_new); the sample variance is M2/(n - 1). It needs three numbers of state and avoids catastrophic cancellation.
Examples
Adding 30, 32 and 31 one at a time gives μ = 31 and M2 = 2, so σ² = 2/(3 − 1) = 1.
The fan's detector keeps only n, μ and M2 per feature, updating once a window without storing past readings.