Trailing vs centered Moving Average

Highly appreciate if someone would give some intuition on this statement (below) with examples ?

“Then moving averages using centered windows can be more accurate than using trailing windows. But we can’t use centered windows to smooth present values since we don’t know future values. However, to smooth past values we can afford to use centered windows”

Hi, @amitp !

Centered windows take into account the past and future n samples and the present one (center value) to take the average:

\overline{x}_t = \frac{x_{t-n}, x_{t-n-1}, ..., x_{t}, x_{t+1}, .., x_{t+n}}{2n+1}

while trailing windows only use n past samples to calculate it:

\overline{x}_t = \frac{x_{t-n}, x_{t-n-1}, ..., x_{t}}{n}

That’s why you can’t use centered window “online” or with real-time data because you don’t know future values