The TS_DIFF function recursively computes the forward differences of an n -element time-series k times. The result is an n -element differenced time-series with its last k elements as zeros.
This routine is written in the IDL language. Its source code can be found in the file
ts_diff.pro
in the
lib
subdirectory of the IDL distribution.
Define an n -element vector of time-series samples:
X = [389, 345, 303, 362, 412, 356, 325, 375, $
410, 350, 310, 388, 399, 362, 325, 382, $
399, 382, 318, 385, 437, 357, 310, 391]
PRINT, TS_DIFF(X, 2) ; Compute the second forward differences of X.
2 101 -9 -106 25 81 -15 -95 20