Skip to content

Function: rolling() ​

ts
function rolling(values, options, fn?, functionArgs?, times?): number[];

A rolling statistic (pandas' series.rolling(window, min_periods, center, win_type).fn()): for each point, fn of the present values in its window. times (ms) are the index for a time-span window and must be sorted.

Parameters ​

ParameterTypeDefault value
valuesArrayLike<number>undefined
optionsRollingOptionsundefined
fnWindowFunction'mean'
functionArgsReadonly<Record<string, unknown>>{}
times?ArrayLike<number>undefined

Returns ​

number[]

Example ​

ts
rolling([1, 2, NaN, 4, 5], { window: 2 }, 'mean'); // [NaN, 1.5, NaN, NaN, 4.5]

Released under the MIT License.