Re: [Numpy-discussion] Second order gradient in numpy

2014-05-03 Thread RayS
I recently tried diff and gradient for some medical time domain data, and the result nearly looked like pure noise. I just found this after seeing John Agosta's post https://gist.github.com/mblondel/487187 Find the solution for the second order differential equation u'' = -u with u(0) = 10

Re: [Numpy-discussion] Second order gradient in numpy

2014-05-02 Thread Yuxiang Wang
Hi Chris, Thank you! This is useful information. Unfortunately, I am doing this on data from a sensor and would be hard to fit to a simple polynomial while avoiding overfitting. Thanks again! Shawn On Thu, May 1, 2014 at 7:01 PM, Chris Barker chris.bar...@noaa.gov wrote: On Thu, May 1, 2014

Re: [Numpy-discussion] Second order gradient in numpy

2014-05-02 Thread Yuxiang Wang
Hi Christian, Thank you for your input! I prefer np.gradient because it takes mid-point finite difference estimation instead of one-sided estimates, but np.diff() is also a good idea. Just wondering why np.gradient does not have something similar, being curious :) Shawn On Thu, May 1, 2014 at

Re: [Numpy-discussion] Second order gradient in numpy

2014-05-02 Thread Chris Barker
On Thu, May 1, 2014 at 6:00 PM, Yuxiang Wang yw...@virginia.edu wrote: Thank you for your input! I prefer np.gradient because it takes mid-point finite difference estimation instead of one-sided estimates, but np.diff() is also a good idea. Just wondering why np.gradient does not have

Re: [Numpy-discussion] Second order gradient in numpy

2014-05-02 Thread John Mark Agosta
Shawn (Yuxiang) - The right way to compute this is using Runga-Kutta approximations. I'm not aware if numpy supports these. -jm __ John Mark Agosta 650 465-4707 johnmark.ago...@gmail.com *Unpredictable consequences are the most expected thing on earth.* *

[Numpy-discussion] Second order gradient in numpy

2014-05-01 Thread Yuxiang Wang
Hi all, I am trying to calculate the 2nd-order gradient numerically of an array in numpy. import numpy as np a = np.sin(np.arange(0, 10, .01)) da = np.gradient(a) dda = np.gradient(da) This is what I come up. Is the the way it should be done? I am asking this, because in numpy

Re: [Numpy-discussion] Second order gradient in numpy

2014-05-01 Thread Christian K.
Am 01.05.14 18:45, schrieb Yuxiang Wang: Hi all, I am trying to calculate the 2nd-order gradient numerically of an array in numpy. import numpy as np a = np.sin(np.arange(0, 10, .01)) da = np.gradient(a) dda = np.gradient(da) It looks like you are looking for the

Re: [Numpy-discussion] Second order gradient in numpy

2014-05-01 Thread Chris Barker
On Thu, May 1, 2014 at 3:42 PM, Christian K. ckk...@hoc.net wrote: It looks like you are looking for the derivative rather than the gradient. Have a look at: np.diff(a, n=1, axis=-1) n is the order if the derivative. depending on your use case, you may want to use a polynomial fit for a