What implicit function used for gradient descent in numpy gradient? TL;DR numpy.gradient calculates the gradient of an ndarray, but I am not clear as to what it is with respect to what original function. 
An example, (although I might be wrong in understanding so appreciate clarity) 
Say we have an (2, 2) ndarray representing some image data, then we can say: pixel = f(x, y), so we can do partials of dp/dy and dp/dx, and I think such an approach is used in edge detection in image processing. So I did this with np.gradient and it did provide correct results. I looked through the gradient source code and see that it uses central differences, but I am not clear, what original function does it assume created the value? Surely we need to know the original function/first derivative and even if we use just taylor based approximations, don't we need to know the original f? Can we always get always with just doing differences? 
 A: The derivative of a function $f$ can be approximated at a point $x$ by finite differencing. For example, using the central difference where $\Delta$ is some small value:
$$\frac{d}{dx} f(x) \approx \frac{f(x+\Delta) - f(x-\Delta)}{2\Delta}$$
Now, suppose we don't know the expression for $f$. But, we have an evenly spaced grid of points $\{x_1, \dots, x_n\}$ and the corresponding function values $\{y_1, \dots, y_n\}$, where $y_i = f(x_i)$. Then, we can still use finite differencing to approximate the derivative at each point as above, provided the grid spacing is small enough. For the middle points ($x_2, \dots, x_{n-1}$):
$$\frac{d}{dx} f(x_i) \approx \frac{y_{i+1} - y_{i-1}}{x_{i+1}-x_{i-1}}$$
As above, this is just the change in function value divided by the change in the input. Central differences can't be used at the edge points ($x_1$ and $x_n$) but the concept is the same.
So, sampled values are sufficient for numerically approximating the derivative of a function, and the function itself isn't necessary. The case is similar for approximating the gradient (i.e. partial derivatives) of functions of multiple variables--simply perform finite differencing along each direction.
