Collection of online algorithms. Most of them are online versions of their offline counterparts in numpy, but because of their online nature, they are formulated as classes instead of functions.
For further information about online algorithms, please check Wikipedia: http://en.wikipedia.org/wiki/Online_algorithm
Usage is as follows:
Most classes accept scalar values as well as n-dimensional arrays, as well as many different data types. Check the documentation of the respective class for further details.
Online algorithm to compute the sample arithmetic mean (average), plus the corresponding sample variance.
To be specific, the algorithm calculates an estimator for the sample average and an estimator for the sample variance.
After creating an instance of this class, add values to it using the method add. After at least one value has been added, the result can be obtained by calling the instance or the method mean. Sample variance, sample standard deviation and sample standard error can be obtained by calling the methods var, std and stderr.
Working principle:
Besides the sample count N, the class only has to remember two other values (scalar or nd-array):
With this information, it is easy to calculate the arithmetic mean and the sample variance:
mean = sigma/N
var = 1/(N-1)*sigma2-sigma**2/(N*(N-1))
Online algorithm to compute the sample geometric mean, plus the corresponding variance.
To be specific, the algorithm calculates an estimator for the sample geometric mean and an estimator for the corresponding sample variance.
After creating an instance of this class, add values to it using the method add(). After at least one value has been added, the result can be obtained by calling the instance or the method gmean(). Sample variance, sample standard deviation and sample standard error can be obtained by calling the methods var(), std() and stderr().
Working principle:
Besides the sample count N, the class only has to remember two other values (scalar or nd-array):
With this information, the sample geometric mean and the sample variance can be calculated as follows:
mean = exp(gamma/N)
var = exp(2*gamma/N)*(1/(N-1)*gamma2-gamma**2/(N*(N-1)))