[Numpy-discussion] Dealing with roundoff error

Mike Sarahan msarahan at gmail.com
Sat Mar 27 19:38:27 EDT 2010

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:

However, even linspace shows roundoff error:

np.sum(a[1:]==b[:-1])  # Gives me 72, no 100

What is the best way to deal with it?  Multiply the intervals by 10,
then convert them to ints?


More information about the NumPy-Discussion mailing list