Skip to content

What (One-liner)

Rolling window mean, None value filter. Library-level primitive.

How to use

python
from services.algo.statistics import rolling_mean
rolling_mean([1, 2, 3, 4, 5], window=3)
# → [None, None, 2.0, 3.0, 4.0]

Core formulas

out_t = mean([s for s in series[t-w+1..t] if s is not None])  if valid >= 1 else None

Assumptions & applicability

Assumptions: Left-aligned + None filter + w<=n.

Applicability: macro smoothing, rolling baseline, simple denoising.

Not Applicable: weighted (use EMA), streaming.

Known limitations

  1. Left-aligned hardcoded
  2. None filter (no forward-fill)
  3. window=3 default

References

Brockwell & Davis (2016) Time Series Forecasting.

Golden Test

tests/golden/fixtures/tier1/rolling_mean/, 1e-12, 2026-04-20 passing.

Changelog

  • 1.0.0 (2026-04-20) — First Active

Verifiable intelligence for the decisions that demand scrutiny.