Package igraph :: Module statistics :: Class RunningMean
[hide private]
[frames] | no frames]

Class RunningMean

object --+
         |
        RunningMean

Running mean calculator.

This class can be used to calculate the mean of elements from a list, tuple, iterable or any other data source. The mean is calculated on the fly without explicitly summing the values, so it can be used for data sets with arbitrary item count. Also capable of returning the standard deviation (also calculated on the fly)

Instance Methods [hide private]
 
__complex__(self)
 
__float__(self)
 
__init__(n=0.0, mean=0.0, sd=0.0)
Initializes the running mean calculator.
 
__int__(self)
 
__long__(self)
 
__lshift__(RunningMean, values)
Adds the values in the given iterable to the elements from which we calculate the mean.
 
__str__(self)
str(x)
 
_get_mean(self)
 
_get_result(self)
 
_get_sd(self)
 
add(RunningMean, value, repeat=1)
Adds the given value to the elements from which we calculate the mean and the standard deviation.
 
add_many(RunningMean, values)
Adds the values in the given iterable to the elements from which we calculate the mean.

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__

Properties [hide private]
  mean
the current mean
  result
the current mean and standard deviation as a tuple
  sd
the current standard deviation

Inherited from object: __class__

Method Details [hide private]

__init__(n=0.0, mean=0.0, sd=0.0)
(Constructor)

 

Initializes the running mean calculator. Optionally the number of already processed elements and an initial mean can be supplied if we want to continue an interrupted calculation.

Parameters:
  • n - the initial number of elements already processed
  • mean - the initial mean
  • sd - the initial standard deviation
Overrides: object.__init__

__lshift__(RunningMean, values)

 

Adds the values in the given iterable to the elements from which we calculate the mean. Can also accept a single number. The left shift (<<) operator is aliased to this function, so you can use it to add elements as well:

>>> rm=RunningMean()
>>> rm << [1,2,3,4]
(2.5, 1.6666666666667)
Parameters:
  • values (iterable) - the element(s) to be added
Returns:
the new mean

__str__(self)
(Informal representation operator)

 

str(x)

Overrides: object.__str__
(inherited documentation)

add(RunningMean, value, repeat=1)

 

Adds the given value to the elements from which we calculate the mean and the standard deviation.

Parameters:
  • value - the element to be added
  • repeat - number of repeated additions
Returns:
the new mean and standard deviation as a tuple

add_many(RunningMean, values)

 

Adds the values in the given iterable to the elements from which we calculate the mean. Can also accept a single number. The left shift (<<) operator is aliased to this function, so you can use it to add elements as well:

>>> rm=RunningMean()
>>> rm << [1,2,3,4]
(2.5, 1.6666666666667)
Parameters:
  • values (iterable) - the element(s) to be added
Returns:
the new mean

Property Details [hide private]

mean

the current mean

Get Method:
_get_mean(self)

result

the current mean and standard deviation as a tuple

Get Method:
_get_result(self)

sd

the current standard deviation

Get Method:
_get_sd(self)