Notes

Differencing

Differencing is a simple trick for turning a “wandering” time series into one that’s easier to model. Instead of working with the raw values (like house prices), you work with how much they change from one time step to the next.

What differencing does

Differencing transforms a time series by subtracting previous values from current ones. The most common version is first-order differencing:

diff_t = y_t - y_{t-1}

This often removes a trend, helping the series become more stationary (its average level and variability stay roughly stable over time). If one round isn’t enough, you can apply second-order differencing:

diff2_t = (y_t - y_{t-1}) - (y_{t-1} - y_{t-2})

Intuition and a quick analogy

Raw values are like your altitude during a hike: it can steadily climb or fall. Differenced values are like your step-by-step elevation change—much more stable and comparable across the route.

Practical examples

  • House prices: prices trend upward over years; differencing yields month-to-month price changes.
  • Sales: weekly sales may grow with the business; differencing focuses on weekly gains/losses.
  • Medical measurements: a patient’s baseline may drift; differencing highlights sudden changes.

Why it matters in AI/ML

Many forecasting models assume stationarity or behave better with it. Differencing is central to ARIMA (the “I” is “Integrated,” meaning differenced). It can also improve feature quality for ML models by reducing spurious correlations driven by shared trends. A key caution: too much differencing can amplify noise and make forecasts harder to interpret, so the differencing order is usually kept small and checked with residual diagnostics.

Differencing is a time-series transformation that replaces each value with the change from a previous value (e.g., first difference: yt − yt−1). It is used to remove trends and reduce non-stationarity, making many statistical models (e.g., ARIMA) valid and easier to fit. For example, differencing daily sales can stabilize the mean so autocorrelation reflects short-term dynamics rather than long-run growth.

Imagine tracking your height on a wall each year. The exact heights keep going up, but the changes from year to year might be more stable and easier to compare. Differencing does the same thing for data measured over time: instead of using the raw values, it looks at how much the value changed since the previous time point (today minus yesterday, this month minus last month).

In time series work and AI forecasting, differencing helps remove steady trends or repeating growth so the series becomes more “steady” over time, which often makes patterns easier for models to learn.