more precise way of calculating moving average

avoid resampling