Second-Order Differentiation#
The second difference detrending calculates the difference of differences, which is a common method for detrending time series. It works by computing the difference between consecutive first differences, effectively removing both constant offsets and linear trends from the data. Just as acceleration represents the change in velocity, the second difference captures the change in the rate of change of the time series.
from delaynet.detrending_methods import second_difference
# Apply second difference detrending
detrended_ts = second_difference(time_series)
Note that the length of the time series is reduced by 2 after applying this detrending.
- detrending_methods.second_difference()
Second difference (2diff) detrending.
- Parameters:
ts (numpy.ndarray) – Time series to detrend.
- Returns:
Detrended time series (length is reduced by 2).
- Return type: