Tag Archives: sliding window average

Moving Average of Last N numbers in a Stream

Design a class to calculate moving average of last N numbers in a stream of real numbers For example, if N=3 and the stream S=[2,3,4,1,2,-3,0,…] then moving averages at each each streamed number are = [2.0, 2.5, 3.0, 2.66, 2.33, 0, -0.33,…]. We need to design in a way that when a new element ins […]