More generally, however, the numerical derivative of a suitably filtered signal
\(y\left(x\right)\) can also be evaluated at each
\(x\) value using the
numpy
function
gradient
where for a 1D array of data the gradient will be the same as the derivative
\(\frac{dy}{dx}\). According to the
numpy.gradient
reference page , this function "calculates the gradient using second order accurate central differences in the interior points and either first or second order accurate one-sides (forward or backwards) differences at the boundaries. " It also has the advantage of not requiring equally spaced data values. See the
reference page for further examples and details.