Calculate the moving average from an array.