CF Step project utilities.

Moving average

This simple function computes the moving average over a sliding window for a given list.

moving_avg[source]

moving_avg(inputs:list, w:int=10)

Computes the moving average of a list over a sliding window.

Arguments:

  • inputs (list): A list of integers or floats
  • w (int): The sliding window that will be used to compute moving averages
a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

moving_avg(a, 2)
[1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5]