Average between n numbers
I'll assume that you are computing the average of the elements of an array of fixed size and that you can change the value at some position at any moment. You want a data structure that supports the following two operations:


Update element at location $i$,
Query sum of elements in range [$i$, $j$].


A binary indexed tree (aka Fenwick tree) performs both in $\cal O(\lg n)$.