nectarchain.utils.stats.Stats#

class Stats(shape=(1,))[source]#

Bases: object

class 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

add

Add entry.

copy

get_lowcount_mask

merge

Merge this accumulator with another one.

Attributes

count

max

mean

min

shape

std

stddev

variance

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

merge(other)[source]#

Merge this accumulator with another one.

Parameters:
other: nectarchain.utils.stats.Stats

Another object of the same type which you want to combined the statistics