np_diff
- dtaianomaly.utils.np_diff(x)[source]
Numba implementation for np.diff(x).
Computes the difference of each pair of consecutive values, i.e., the element at position \(i\) in the output is computed as element \(i\) in
xsubtracted from element \(i+1\) inx. Consequently, the output will have one element less than the given array.- Parameters:
- xnp.array of shape (N,)
The array on which the difference should be computed.
- Returns:
- np.array of shape (N-1,)
Identical as np.diff(x)
Examples
>>> import numpy as np >>> from dtaianomaly.utils import np_diff >>> np_diff(np.array([0, 3, 4, 2, 6, 1])) array([ 3, 1, -2, 4, -5])