TS_DIFF

The TS_DIFF function recursively computes the forward differences of an n-element time-series k times. 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.

Examples

; 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]

; Compute the second forward differences of X:

PRINT, TS_DIFF(X, 2)

IDL prints:

  2  101   -9 -106   25   81  -15  -95   20

118  -67  -48    0   94  -40  -34  -47  131

-15 -132   33  128    0    0

Syntax

Result = TS_DIFF( X, K [, /DOUBLE] )

Return Value

The result is an n-element differenced time-series with its last k elements as zeros.

Arguments

X

An n-element integer, single- or double-precision floating-point vector containing time-series samples.

K

A positive integer or long integer scalar that specifies the number of times X is to be differenced. K must be in the interval [1, N_ELEMENTS(X) - 1].

Keywords

DOUBLE

Set this keyword to force the computation to be done in double-precision arithmetic.

Version History

4.0

Introduced

See Also

SMOOTH, TS_FCAST