Differencing is a transformation that converts a non-stationary time series into a stationary one by computing the change between consecutive observations. First-order differencing removes linear trends, second-order removes quadratic trends, and so on. It is a key preprocessing step for ARIMA models which require stationarity.
Given a time series and a differencing order d, apply d rounds of first-order differencing.
First-order differencing computes:
Δx[t]=x[t]−x[t−1]For order d, apply this operation d times. Each round reduces the length by 1, so the output has length n - d.
Return a list with length equal to the input length minus order.
Input: series = [1, 3, 6, 10, 15], order = 1
Output: [2, 3, 4, 5]
Explanation: Each output is the current value minus the previous value.
Input: series = [1, 3, 6, 10, 15], order = 2
Output: [1, 1, 1]
Copy the series, then repeat first-order differencing order times.
Replace the working list with adjacent differences after each round.
Sign in to take notes on this problem
Accepts: array
Accepts: number
Differencing is a transformation that converts a non-stationary time series into a stationary one by computing the change between consecutive observations. First-order differencing removes linear trends, second-order removes quadratic trends, and so on. It is a key preprocessing step for ARIMA models which require stationarity.
Given a time series and a differencing order d, apply d rounds of first-order differencing.
First-order differencing computes:
Δx[t]=x[t]−x[t−1]For order d, apply this operation d times. Each round reduces the length by 1, so the output has length n - d.
Return a list with length equal to the input length minus order.
Input: series = [1, 3, 6, 10, 15], order = 1
Output: [2, 3, 4, 5]
Explanation: Each output is the current value minus the previous value.
Input: series = [1, 3, 6, 10, 15], order = 2
Output: [1, 1, 1]
Copy the series, then repeat first-order differencing order times.
Replace the working list with adjacent differences after each round.
Sign in to take notes on this problem
Accepts: array
Accepts: number