Back to Numerical Arrays (NumPy)
np.diff
Calculate the n-th discrete difference along the given axis.
Syntax
np.diff(a, n?, axis?)
Description
Calculate the n-th discrete difference along the given axis. The first difference is given by out[i] = a[i+1] - a[i] along the given axis, higher differences are calculated by using diff recursively.
Parameters
| Name | Description |
|---|---|
| a | - Input array |
| n(optional) | - The number of times values are differenced. If zero, the input is returned as-is. |
| axis(optional) | - The axis along which the difference is taken, default is the last axis. |
Returns
Promise<NDArray>