- npstreams.average_and_var(arrays, axis=-1, ddof=0, weights=None, ignore_nan=False)¶
Calculate the simultaneous average and variance of a stream of arrays. This is done in single iteration for maximum performance.
New in version 1.6.1.
arrays (iterable of ndarrays) – Arrays to be combined. This iterable can also a generator.
axis (int, optional) – Reduction axis. Default is to combine the arrays in the stream as if they had been stacked along a new axis, then compute the variance along this new axis. If None, arrays are flattened. If axis is an int larger that the number of dimensions in the arrays of the stream, variance is computed along the new axis.
ddof (int, optional) – Means Delta Degrees of Freedom. The divisor used in calculations is
N - ddof, where
Nrepresents the number of elements.
weights (iterable of ndarray, iterable of floats, or None, optional) – Iterable of weights associated with the values in each item of arrays. Each value in an element of arrays contributes to the variance according to its associated weight. The weights array can either be a float or an array of the same shape as any element of arrays. If weights=None, then all data in each element of arrays are assumed to have a weight equal to one.
ignore_nan (bool, optional) – If True, NaNs are set to zero weight. Default is propagation of NaNs.
average (~numpy.ndarray) – Average, possibly weighted.
var (~numpy.ndarray) – Variance, possibly weighted.
Since the calculation of the variance requires knowledge of the average, this function is a very thin wrapper around var.
D. H. D. West, Updating the mean and variance estimates: an improved method. Communications of the ACM Vol. 22, Issue 9, pp. 532 - 535 (1979)