Skip to content

Documentation / @finchart/indicators / StddevFold

Interface: StddevFold ​

Defined in: indicators/src/kernels.ts:452

The windowed population standard deviation as a fold — and the one copy of the arithmetic: the array stddev is this fold in a loop.

Numerics, since a variance is where running sums fail: Σy²/n − mean² cancels catastrophically when the spread is small next to the level (prices near 1e6 with a spread of 0.03 came out 700% wrong — measured), and an incremental update that subtracts a departing value cancels again whenever that value dwarfs what remains (a 1e9 spike leaving a window of 1e6 prices left the residual 20% wrong; two such departures in a row slipped past a guard). So nothing is subtracted, ever: each step sweeps the window twice — a mean, then squared deviations — with every value taken relative to the window's oldest value so the sums are the size of the spread, not the level. O(period) per step by design; period is in the tens, and the tick's own slice + concat over the whole history is a hundred thousand pointers. The state is just the ring.

Methods ​

restore() ​

restore(state): void

Defined in: indicators/src/kernels.ts:455

Parameters ​

state ​

StddevState

Returns ​

void


snapshot() ​

snapshot(): StddevState

Defined in: indicators/src/kernels.ts:454

Returns ​

StddevState


step() ​

step(value): number | null

Defined in: indicators/src/kernels.ts:453

Parameters ​

value ​

number | null

Returns ​

number | null