IncrementalMoments¶
Defined in fynance.features.engineering
- class IncrementalMoments[source]
Bases:
objectOnline mean / variance via Welford’s algorithm (O(1) per update).
Streaming alternative to recomputing a rolling mean/variance from scratch.
- Attributes:
- nint
Number of observations seen.
- meanfloat
Running mean.
Examples
>>> im = IncrementalMoments() >>> for v in [1.0, 2.0, 3.0]: ... _ = im.update(v) >>> im.mean, round(im.var, 4) (2.0, 0.6667)
- property std
Population standard deviation.
- update(x)[source]
Incorporate one observation; return self for chaining.
- property var
Population variance (0 before the second observation).