Re: [Numpy-discussion] Dealing with roundoff error

2010-03-29 Thread Mike Sarahan
Thank you all for your suggestions. I ended up multiplying by 10 and rounding, while casting the array to an int. Certainly not the most universal solution, but it worked for my data. code, for anyone searching for examples: np.array(np.round((hlspec[:,0]-offset)*10),dtype=np.int) -Mike On Sun

Re: [Numpy-discussion] Dealing with roundoff error

2010-03-28 Thread Friedrich Romstedt
2010/3/28 Mike Sarahan : > I have run into some roundoff problems trying to line up some > experimental spectra.  The x coordinates are given in intervals of 0.1 > units.  I read the data in from a text file using np.loadtxt(). I don't know your problem well enough, so the suggestion to use numpy.

Re: [Numpy-discussion] Dealing with roundoff error

2010-03-28 Thread Anne Archibald
On 27 March 2010 19:38, Mike Sarahan wrote: > Hi all, > > I have run into some roundoff problems trying to line up some > experimental spectra.  The x coordinates are given in intervals of 0.1 > units.  I read the data in from a text file using np.loadtxt(). > > I think Robert's post here explains

Re: [Numpy-discussion] Dealing with roundoff error

2010-03-27 Thread Pauli Virtanen
Mike Sarahan wrote: > However, even linspace shows roundoff error: > > a=np.linspace(0.0,10.0,endpoint=False) > b=np.linspace(0.1,10.1,endpoint=False) > np.sum(a[1:]==b[:-1])  # Gives me 72, no 100 Are you sure equally spaced floating point numbers having this property even exist? 0.1 does not ha

[Numpy-discussion] Dealing with roundoff error

2010-03-27 Thread Mike Sarahan
Hi all, I have run into some roundoff problems trying to line up some experimental spectra. The x coordinates are given in intervals of 0.1 units. I read the data in from a text file using np.loadtxt(). I think Robert's post here explains why the problem exists: http://mail.scipy.org/pipermail/