What You'll Learn
You'll learn how to compute a simple moving average by taking the unweighted mean of the last n observations within a sliding window.
The Core Idea
A Simple Moving Average (SMA) smooths out short-term fluctuations in your time series by averaging the most recent n data points. The word "moving" means the window slides forward one observation at a time, constantly recalculating the average with the newest data while dropping the oldest.
Think of it like tracking your average coffee spending over the last 7 days. On Monday, you average Days 1–7. On Tuesday, you drop Day 1, add Day 8, and average Days 2–8. The window keeps "moving" forward.
Why It's "Simple"
Unlike weighted moving averages (which we haven't covered yet), the SMA treats all n observations in the window equally. Each observation contributes 1/n to the average—no observation is more important than another within that window.
The Formula
For a window size n, the SMA at time t is:
SMA(t) = (x(t) + x(t-1) + x(t-2) + ... + x(t-n+1)) / n
Where x(t) is the observation at time t.
Choosing Window Size
- Smaller n: More responsive to recent changes, but noisier
- Larger n: Smoother curve, but lags behind actual trend more
A 7-day SMA reacts faster than a 30-day SMA, but the 30-day version removes more noise.
What SMA Does
The SMA helps you see the underlying trend by filtering out irregular, short-term variations (the random noise component). It's particularly useful for visualizing patterns and as a simple forecasting baseline.
Key Takeaway: The Simple Moving Average computes an unweighted mean over a sliding window of n observations, smoothing time series data by treating all points in the window equally—larger windows create smoother trends but respond more slowly to changes.