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, $\hat{x}$ 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 $n$ can be calculated by using new value $x_n$ and previous average value $\hat{x}_{n-1}$. In other words, I can save a great amount of memory and it’s very convenient.