usual me usual me - 1 year ago 136
Python Question

What does numpy.gradient do?

So I know what the gradient of a (mathematical) function is, so I feel like I should know what

does. But I don't. The documentation is not really helpful either:

Return the gradient of an N-dimensional array.

What is the gradient of an array? When is

Answer Source

The gradient is computed using central differences in the interior and first differences at the boundaries.


The default distance is 1

This means that in the interior it is computed as

enter image description here

where h = 1.0

and at the boundaries

enter image description here

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download