Skip to content

Function: ewm() ​

ts
function ewm(values, options, fn?): number[];

An exponentially weighted statistic (pandas' series.ewm(…).mean() / .sum() / .var() / .std(), a port of pandas' ewm and ewmcov loops). With adjust (default) the mean at t is Σ (1 − α)^i x_{t−i} / Σ (1 − α)^i over present values; missing values keep the previous result and, unless ignoreNa, still age the weights. var and std are bias-corrected.

Parameters ​

ParameterTypeDefault value
valuesArrayLike<number>undefined
optionsEwmOptionsundefined
fnEwmFunction'mean'

Returns ​

number[]

Example ​

ts
ewm([1, 2, 3, 4], { alpha: 0.2 }); // [1, 1.555556, 2.147541, 2.775068]

Released under the MIT License.