← All simulations · Pillar 7: Patterns in time
Trends & seasons
What it is
Two years of monthly temperatures make a wiggly line. Hidden inside it are two tidy parts: a slow trend — a gentle drift up or down over the whole stretch — and a repeating season — the swing that comes back every year, warm in summer and cool in winter. Pulling a wiggly line apart into trend, season, and leftover noise is called decomposition.
Go deeper: we find the trend by drawing the straight line that best fits the whole record. Subtract it and what’s left is the pure wiggle. To find the season we fold that wiggle into repeats of some length and average each position. Only when the length matches the real cycle do the folded pieces land on top of each other — January with January, July with July — revealing one clean seasonal wave. Add it back to the trend and you have rebuilt the line, leaving just small noise.
Why care
Almost everything measured over time has this shape: sales, website visits, rainfall, a city’s electricity use. If you don’t separate the trend from the season you can fool yourself — “sales jumped in December!” might just be the yearly holiday season, not real growth. Splitting the two lets you answer the real questions: which way is it heading overall, and what part simply repeats? It’s also the first step before smoothing a line or forecasting what comes next.
The idea, intuitively
Imagine cutting the two-year line into equal lengths and stacking them like sheets of tracing paper. If you cut at the wrong length, the sheets don’t match and you see a blur. Slide the cut length until the sheets suddenly line up into one shape — that length is how long the season takes to repeat. Here, the sheets snap together at 12 months.
Peek at the data first
Each row is one month and its average temperature. Two whole years means
any yearly pattern appears twice — which is exactly what lets us check that it repeats. This is
the kind of summary Spectra’s describe_data gives before you trust a dataset.
Try it
The top chart shows the wiggly temperature line, the dashed trend line, and the orange trend + season rebuild. The bottom chart folds the de-trended wiggle into repeats of the length you choose. Slide repeat length and watch the grey folded cycles snap on top of each other — and the rebuild lock onto the line — right at 12 months.
Where it shows up
- Business & demand. Stores split sales into a growth trend and a holiday season so they can stock the right amount and spot real change.
- Energy & weather. Power grids and climate scientists separate long-term drift from the daily and yearly cycles.
- Health & web traffic. Flu cases and website visits both carry weekly and yearly seasons on top of a slower trend.
Where it came from
Splitting a time series into trend and season is an old idea from economics and astronomy. Statisticians worked out moving-average decomposition in the early 1900s, and national statistics offices built “seasonal adjustment” methods — like the U.S. Census Bureau’s X-11 in the 1960s — to strip the yearly cycle out of economic numbers so the real trend could be seen. The same idea now lives inside modern forecasting tools.
Try it in code
In the Studio, load a time-based dataset and plot it to see the trend and
season with your own eyes — the first look before any decomposition:
data = load "weather_town" describe_data data plot_data data, x: "day", y: "temperature"
Check your understanding
- What is the difference between a trend and a season?
- Why do the folded cycles only line up at the right repeat length?
- Why might “sales rose in December” be misleading without removing the season first?