Trend, Seasonality & Decomposition

P7.ts-foundations.02 · Audience: guest, it-ml, language-pro · Prerequisites: What Makes Data a Time Series?

The previous module named the four ingredients of a series — level, trend, seasonality, noise. This module makes the separation mechanical: a moving average to lift out the trend, a per-position average to lift out the season, and whatever remains is the residual. The whole procedure is arithmetic you can check by hand, and by the end you will read a three-panel decomposition plot the way a doctor reads an X-ray.

Step 1 / 5Two patterns in one line

Here is a tiny series, nine days of a quantity that both grows and cycles. It was built from a trend that climbs by 1 each day and a three-day seasonal pattern that repeats +2, −2, 0 — with no noise at all, so every step of the separation can be verified exactly.

Day t123456789
Trend (hidden)101112131415161718
Season (hidden)+2−20+2−20+2−20
Observed y12912151215181518

In real data only the bottom row is observed. The question of this module: given just 12, 9, 12, 15, 12, 15, 18, 15, 18 — can we recover the two hidden rows? The answer is yes, with two averaging tricks.

Ask the mentor about this module

Ask a question about this content. The mentor explains and grounds its answer in what you are studying; asking is recorded as a learning signal, not a grade.

Ctrl/Cmd + Enter to send

Try it yourself

A scratch console for this page's ideas — ungraded, nothing you run here is recorded.

Scratch console

A scratch console with the scientific stack (pandas, numpy, scikit-learn). Runs on the server — no network, resource-limited and measured.

Output appears here.

Where next?