Victor Buendía (@[email protected]) writes:

Turns out that #julialang does not have the equivalent of Numpy’s gradient function. So I went to Numpy docs and source code and adapted it.

Numpy’s gradient is great because it uses centered differences, so it’s way more accurate than naively getting the forward differences. Also, supports non-equally spaced grids.

In case someone needs it (for 1D arrays only), here it is:

https://gist.github.com/VictorSeven/996e0745e820dde0610ada9e9e025844

Source