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

2014-05-01 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 6:

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

2014-05-01 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 wrote: > On Thu, May 1, 2014 at 3:42 PM, Christian

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. 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 higher o

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

[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 t

Re: [Numpy-discussion] arrays and : behaviour

2014-05-01 Thread did did
thanks, it works well see you and thanks again - Original Message - From: Sebastian Berg Sent: 05/01/14 03:54 PM To: numpy-discussion@scipy.org Subject: Re: [Numpy-discussion] arrays and : behaviour On Do, 2014-05-01 at 09:45 -0400, Benjamin Root wrote: > By default, the hold is alre

Re: [Numpy-discussion] arrays and : behaviour

2014-05-01 Thread did did
Thanks all for your help! i will try bye ;-) - Original Message - From: Sebastian Berg Sent: 05/01/14 03:54 PM To: numpy-discussion@scipy.org Subject: Re: [Numpy-discussion] arrays and : behaviour On Do, 2014-05-01 at 09:45 -0400, Benjamin Root wrote: > By default, the hold is already Tru

Re: [Numpy-discussion] arrays and : behaviour

2014-05-01 Thread Sebastian Berg
On Do, 2014-05-01 at 09:45 -0400, Benjamin Root wrote: > By default, the hold is already True. In fact, that might explain some > of the differences in what you are seeing. There are more points in > the second image than in the first one, so I wonder if you are seeing > some leftovers of previous

Re: [Numpy-discussion] arrays and : behaviour

2014-05-01 Thread Benjamin Root
By default, the hold is already True. In fact, that might explain some of the differences in what you are seeing. There are more points in the second image than in the first one, so I wonder if you are seeing some leftovers of previous plot commands? One issue I do see is that the slicing is incor

Re: [Numpy-discussion] arrays and : behaviour

2014-05-01 Thread Eelco Hoogendoorn
You problem isn't with colon indexing, but with the interpretation of the arguments to plot. multiple calls to plot with scalar arguments do not have the same result as a single call with array arguments. For this to work as intended, you would need plt.hold(True), for starters, and maybe there are

[Numpy-discussion] arrays and : behaviour

2014-05-01 Thread did did
Hello all and sorry for my bad english, i am a beginner with python and i try to save a lot of data in several folders in a 4D matrix and then to plot two columns of this 4D matrix. Bellow, i have the code to fill my 4D matrix, it works very well : [CODE]matrix4D=[] for i in Numbers: readInFol