python-igraph manual

For using igraph from Python

   Home       Trees       Indices       Help   
Package igraph :: Module statistics :: Class RunningMean
[hide private]

Class RunningMean

source code

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]
 
__init__(items=None, n=0.0, mean=0.0, sd=0.0)
Initializes the running mean calculator.
source code
 
add(RunningMean, value, repeat=1)
Adds the given value to the elements from which we calculate the mean and the standard deviation.
source code
 
add_many(RunningMean, values)
Adds the values in the given iterable to the elements from which we calculate the mean.
source code
 
clear(self)
Resets the running mean calculator.
source code
 
__repr__(self)
repr(x)
source code
 
__str__(self)
str(x)
source code
 
__lshift__(RunningMean, values)
Adds the values in the given iterable to the elements from which we calculate the mean.
source code
 
__float__(self) source code
 
__int__(self) source code
 
__long__(self) source code
 
__complex__(self) source code
 
__len__(self) source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __subclasshook__

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

Inherited from object: __class__

Method Details [hide private]

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

source code 

Initializes the running mean calculator.

There are two possible ways to initialize the calculator. First, one can provide an iterable of items; alternatively, one can specify the number of items, the mean and the standard deviation if we want to continue an interrupted calculation.

Parameters:
  • items - the items that are used to initialize the running mean calcuator. If items is given, n, mean and sd must be zeros.
  • n - the initial number of elements already processed. If this is given, items must be None.
  • mean - the initial mean. If this is given, items must be None.
  • sd - the initial standard deviation. If this is given, items must be None.
Overrides: object.__init__

add(RunningMean, value, repeat=1)

source code 

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

add_many(RunningMean, values)

source code 

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] 
>>> rm.result               # doctest:+ELLIPSIS
(2.5, 1.290994...)
Parameters:
  • values (iterable) - the element(s) to be added

__repr__(self)
(Representation operator)

source code 

repr(x)

Overrides: object.__repr__
(inherited documentation)

__str__(self)
(Informal representation operator)

source code 

str(x)

Overrides: object.__str__
(inherited documentation)

__lshift__(RunningMean, values)

source code 

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] 
>>> rm.result               # doctest:+ELLIPSIS
(2.5, 1.290994...)
Parameters:
  • values (iterable) - the element(s) to be added

Property Details [hide private]

result

Returns the current mean and standard deviation as a tuple

Get Method:
unreachable.result(self) - Returns the current mean and standard deviation as a tuple

mean

Returns the current mean

Get Method:
unreachable.mean(self) - Returns the current mean

sd

Returns the current standard deviation

Get Method:
unreachable.sd(self) - Returns the current standard deviation

var

Returns the current variation

Get Method:
unreachable.var(self) - Returns the current variation

   Home       Trees       Indices       Help