diff
Calculate the n-th discrete difference along the given axis. The first difference is given byout[i] = a[i+1] - a[i] along the specified axis. Higher differences are computed by applying diff recursively.
Returns:
NDArray — The n-th differences. The shape is the same as a except along axis where the dimension is reduced by n (adjusted by any prepend/append).
ediff1d
Compute the differences between consecutive elements of a flattened array, with optional values prepended or appended.
Returns:
NDArray — 1-D array of differences between consecutive elements, optionally with prepended/appended values.
gradient
Return the gradient of an N-dimensional array. The gradient is computed using second-order central differences in the interior and first-order (forward/backward) differences at the boundaries.
Returns:
NDArray when f is 1-D (a single gradient array), NDArray[] when f is N-D with N > 1 (one gradient array per axis).