util::fast_ewma
Concept Overview
Section titled “Concept Overview”One function: a single-pass exponentially weighted moving average with span-style decay, alpha = 2/(window+1), corrected by the accumulated weight so that early values are not dragged toward the seed. It mirrors mlfinlab.util.fast_ewma exactly, which is the point — it is what makes daily volatility and every EWMA-derived feature numerically comparable between this library and a pandas reference implementation.
When to Use
Section titled “When to Use”Use it instead of writing a rolling loop, so that everything downstream — util::volatility’s daily vol, the microstructure feature panel, dynamic threshold series for filters — shares one decay convention. Remember that window is a span rather than a hard lookback: the weight on a point w bars back is (1-alpha)^w, not zero, so the estimate remembers further than the number suggests. Size the span longer than the horizon you are trying to smooth over.
Mathematical Foundations
Section titled “Mathematical Foundations”
Smoothing
Section titled “Smoothing”
Usage Examples
Section titled “Usage Examples”Compute EWMA vector
Section titled “Compute EWMA vector”use openquant::util::fast_ewma::ewma;
let x = vec![1.0, 2.0, 3.0, 4.0];let y = ewma(&x, 3);API Reference
Section titled “API Reference”Python API
Section titled “Python API”fast_ewma.ewma
Rust API
Section titled “Rust API”ewma
Risk Notes and Caveats
Section titled “Risk Notes and Caveats”- Window length controls responsiveness vs smoothness.
- Prefer this helper over ad-hoc loops for consistency.