numpy.gradient()

numpy.gradient

numpy.gradient(f, *varargs, **kwargs) [source]

Return the gradient of an N-dimensional array.

The gradient is computed using second order accurate central differences in the interior and either first differences or second order accurate one-sides (forward or backwards) differences at the boundaries. The returned gradient hence has the same shape as the input array.

Parameters:

f : array_like

An N-dimensional array containing samples