Calculate the nth order discrete difference along given axis.
Parameters: | a : array_like
n : int, optional
axis : int, optional
|
---|---|
Returns: | out : ndarray
|
Examples
>>> x = np.array([0,1,3,9,5,10])
>>> np.diff(x)
array([ 1, 2, 6, -4, 5])
>>> np.diff(x,n=2)
array([ 1, 4, -10, 9])
>>> x = np.array([[1,3,6,10],[0,5,6,8]])
>>> np.diff(x)
array([[2, 3, 4],
[5, 1, 2]])
>>> np.diff(x,axis=0)
array([[-1, 2, 0, -2]])