Foundations✓ Mathematical
◆ The PatternThe simplest way to make a series stationary
Differencing subtracts the previous observation from the current one: Δyt = yt − yt−1. This removes trends. Second differencing removes quadratic trends. Seasonal differencing (yt − yt−m) removes periodic patterns.
Δyt = yt − yt−1 | Δ2yt = Δyt − Δyt−1 | Δmyt = yt − yt−m
The d parameter in ARIMA(p,d,q) is the number of regular differences needed for stationarity.
// Interactive — differencing levels
Differences (d)0
# Python — differencing import pandas as pd diff1 = series.diff().dropna() # first difference diff2 = series.diff().diff().dropna() # second difference sdiff = series.diff(12).dropna() # seasonal difference (m=12)
Don’t over-difference: Each difference removes one degree of integration. If the series is already stationary, differencing adds artificial noise. Check with ADF after each step.
Pattern bridge: Differencing converts levels to returns — exactly what candlestick charts show. In ML, the concept parallels gradient computation: the rate of change matters more than the absolute value.