nectarchain.utils.stats.Stats#
- class Stats(shape=(1,))[source]#
Bases:
objectclass Stats Accumulator object for Welfords online / parallel variance algorithm.
Examples
Example with only one variable >>> from nectarchain.utils.stats import Stats >>> s = Stats() >>> s.add(1) >>> s.add(2) >>> s.add(3) >>> s.mean 2 >>> s.std 1
Initialize with an optional data. For the calculation efficiency, Welford’s method is not used on the initialization process.
Methods
Attributes
countmaxmeanminshapestdstddevvariance- add(element, validmask=None)[source]#
Add entry. If mask is given, it will only update the entry from mask element
- Parameters:
- elementnp.array
array of element to added to the stat object (must be similar shape as the Stats object)
- validmasknp.array
array that indicate which value to use. Only element entry where validmask is True will be added. It must be a boolean array of the same shape as element