maad.util.running_mean
- maad.util.running_mean(x, N, mode='nearest')[source]
Compute fast running mean for a window size N.
- Parameters:
- x1d ndarray of scalars
Vector
- mode{‘reflect’, ‘constant’, ‘nearest’, ‘mirror’, ‘wrap’}, optional,
The mode parameter determines how the input array is extended when the filter overlaps a border. Default is ‘nearest’. Behavior for each valid value is as follows:
- ‘reflect’ (d c b a | a b c d | d c b a)
The input is extended by reflecting about the edge of the last pixel.
- ‘constant’ (k k k k | a b c d | k k k k)
The input is extended by filling all values beyond the edge with the same constant value, defined by the cval parameter.
- ‘nearest’ (a a a a | a b c d | d d d d)
The input is extended by replicating the last pixel.
- ‘mirror’ (d c b | a b c d | c b a)
The input is extended by reflecting about the center of the last pixel.
- ‘wrap’ (a b c d | a b c d | a b c d)
The input is extended by wrapping around to the opposite edge.
- Nint
length of window to compute the mean
- Returns:
- x_mean1d ndarray of scalars
Vector with the same dimensions than the original variable x
Examples
>>> maad.util.running_mean([2, 8, 0, 4, 1, 9, 9, 0], N=3) array([4, 3, 4, 1, 4, 6, 6, 3])