movingaverage

utils.movingaverage(data, windowSize, edgeCorrection=False)[source]

Average over an array

Parameters:
  • data (list of floats) – The data to average
  • windowSize (int) – The size of the window
  • edgeCorrection (bool) – If True the edges are repaired so that there is no unusual dropoff
Returns:

convolution

Return type:

array

Examples

>>> movingaverage([1, 1, 1, 1, 1], 3)
array([0.66666667, 1.        , 1.        , 1.        , 0.66666667])
>>> movingaverage([1, 1, 1, 1, 1, 1, 1, 1], 4)
array([0.5 , 0.75, 1.  , 1.  , 1.  , 1.  , 1.  , 0.75])
>>> movingaverage([1, 1, 1, 1, 1], 3, edgeCorrection=True)
array([1., 1., 1., 1., 1.])