param alpha export class EWMA { private prevValue : number ; private filled = false ; constructor ( private alpha = 0.2 ) { } nextValue ( value ) { const ewma = this . alpha * value + ( 1 - this . alpha ) * ( this . prevValue || 1 ) ; this . filled = this . filled || this . prevValue !== undefined ; this . prevValue = ewma ; if ( this . filled ) { return ewma ; } } momentValue ( value ) { if ( this . filled ) { return this . alpha * value + ( 1 - this . alpha ) * ( this . prevValue || 1 ) ; } } }