A compact math-and-code example
2026-01-15
Every observation pulls; the residuals sum to zero.
\bar{x}_n = \frac{1}{n}\sum_{i=1}^{n} x_i
\bar{x}_n = \bar{x}_{n-1} + \frac{x_n - \bar{x}_{n-1}}{n}
The new observation changes the old mean by a shrinking fraction of its surprise.
If the code only fits when microscopic, show less code.
| Form | Makes visible | Useful when |
|---|---|---|
| Sum | All observations contribute equally | Explaining the estimand |
| Update | One state changes at a time | Streaming or teaching |
After each update, what quantity should equal the mean of all values seen so far?
Good code can reveal the structure already present in the mathematics.