Recently, I have played with time-series in a real-time production. In my case, every single time, there are new data points appended makes my series longer. Gradually, its length will exceed computer memory which leads an obstacle to any computing using the entire array as an input. I found an alternative way at wiki and stackexchange, below I show a note to elaborate.

Say, I managed to compute

Obviously, does need values that start from beginning to current time-point. It’s worth in following an incremental manner in which result is updated repeatedly. For that reason, let me change above formula slightly.

It can be seen that average value at time point can be calculated by using new value and previous average value . In other words, I can save a great amount of memory and it’s very convenient. :+1:


Bryan Nguyễn

Full Stack-Over-Flow Engineer