← Lessons

quiz vs the machine

Gold1320

Machine Learning

The Moving Average Smoothing

Averaging a sliding window to reveal the underlying trend through the noise.

4 min read · core · beat Gold to climb

The Moving Average Smoothing

A moving average replaces each point with the average of nearby points inside a sliding window. It is the simplest way to see a trend through noisy data.

How the window works

  • Choose a window size, such as seven days.
  • For each position, average the values inside the window.
  • Slide the window forward one step and repeat.

A larger window smooths more aggressively but reacts slowly to real changes. A smaller window stays responsive but leaves more noise.

Centered and trailing

  • A centered moving average uses points before and after the current time, which is great for analysis but uses future data.
  • A trailing moving average uses only past points, which is required when forecasting in real time.

What it is good for

Smoothing exposes the trend and dampens random spikes. It can also serve as a crude baseline forecast by carrying the last average forward. Be aware that it lags behind sharp turns and cannot capture seasonality on its own.

Key idea

A moving average trades responsiveness for smoothness, revealing the trend by averaging a sliding window of values.

Check yourself

Answer to earn rating on the learn ladder.

1. What happens as you increase the moving average window size?

2. Why must forecasting use a trailing rather than centered moving average?