calculate the mean incrementally in constant space