Skip to main content

ewm

Function ewm 

Source
pub fn ewm(values: &[f64], alpha: f64) -> Vec<f64>
Expand description

Exponentially weighted mean with smoothing factor alpha ∈ (0, 1].

ewm[i] = alpha * values[i] + (1 - alpha) * ewm[i-1], seeded with the first non-NULL value — pandas’ ewm(alpha=…, adjust=False).mean().

A NULL contributes no observation: the state carries across it unchanged and is what the row reports, exactly as rolling_mean still reports its window’s mean at a NULL row. The statistic is a property of the samples seen so far, and a row with no sample does not undefine it. Folding the NaN into the recurrence, which is what this used to do, made every row after the first NULL NULL as well.

Matches pandas’ ewm(alpha=…, adjust=False, ignore_na=True).mean().