Computing the Running Average

If you have an average AVE(k) for the first k items X(1), ..., Xk) that you have seen so far, then when you see the k+1st item X(k+1), compute the updated average as

AVE(k+1) = AVE(k) + (X(k+1) - AVE(k)) / (k+1)



[ Back to Assignment Page ]