running_average
- mdtools.statistics.running_average(a, axis=None, out=None)[source]
Calculate the running average.
- Parameters
a (
array_like
) – Array of values for which to calculate the running average.axis (
None
orint
, optional) – Axis along which the running average is computed. The default is to compute the running average of the flattened array.out (
array_like
) – Alternative output array in which to place the result. It must have the same shape and buffer length as the expected output but the type will be cast if necessary. Seenumpy.cumsum()
for more details.
- Returns
rav (
numpy.ndarray
) – The running average along the specified axis. The result has the same size as a, and also the same shape as a if axis is notNone
or a is a 1-d array.
See also
numpy.cumsum()
Return the cumulative sum of the elements along a given axis
Notes
The running average at the \(n\)-position is given by
\[\mu_n = \frac{1}{n} \sum_{i=1}^{n} a_i\]