2 · Trend, seasonality & noise
Almost every series decomposes into three parts: a trend, a repeating seasonal cycle, and residual noise. Separating them is the first thing you do.
A series ≈ trend + seasonality + residual (additive) or trend × seasonality × residual (multiplicative). statsmodels' seasonal_decompose pulls the three apart so you can see, model, and remove each.
Without this:
Without decomposition you model a tangled mess; pulling out trend and seasonality first turns a hard problem into a clean one (model the leftover residual).
Most time series are a sum (or product) of three components:
- Trend (T) — the long-term direction (sales growing year over year).
- Seasonality (S) — a fixed, repeating cycle (more ice cream every summer; more traffic every weekday morning). Seasonality has a known period (7 for weekly, 12 for monthly, 24 for hourly-daily).
- Residual / noise (R) — what's left after removing trend and seasonality; ideally random.
Two models combine them:
- Additive:
y = T + S + R— when the seasonal swing is roughly constant in size. - Multiplicative:
y = T × S × R— when the seasonal swing grows with the level (e.g. ±10%).
statsmodels.tsa.seasonal_decompose estimates all three (the trend via a centred moving average, the seasonality by averaging each position within the period). Decomposition is the first diagnostic you run: it tells you whether there's a trend to remove, how strong the seasonality is, and whether the residual looks like clean noise.
Python (in browser)
statsmodels seasonal_decompose splits the series into trend, a repeating seasonal pattern, and residual noise — the first diagnostic of any forecasting workflow.
Python runs entirely in your browser via Pyodide (~6 MB on first Run, cached after).
Your monthly sales swing by about ±10% of the current level, so the seasonal amplitude grows as sales grow. Which decomposition model fits?
- Series ≈ trend + seasonality + residual (additive) or their product (multiplicative).
- Seasonality has a known period (7 weekly, 12 monthly, 24 hourly); seasonal_decompose estimates all three components.
- Decomposition is the first diagnostic: it reveals trend, seasonality strength, and whether the residual is clean noise.
Decomposition underlies Holt-Winters, SARIMA's seasonal terms, and Prophet's additive trend+seasonality+holidays model.
If you remove it: Without separating components you try to model trend, cycles, and noise all at once — far harder and less interpretable.