[Numpy-discussion] Floating Point Difference between numpy and numarray
Tue Sep 9 12:19:16 CDT 2008
Hanni Ali wrote:
> > Interesting example thanks. I can't however seem to get anything
> other than
> > zero for the 100,000 to 1 sum.
what is the "100,000 to 1 sum." this is my interpretation:
a = np.linspace(100000, 1, 100000)
array([ 1.00000000e+05, 9.99990000e+04, 9.99980000e+04, ...,
3.00000000e+00, 2.00000000e+00, 1.00000000e+00])
which is exact, but it won't be if you use single precision:
>>> a = a.astype(np.float32)
You'd have to use tricks like compensated summation and the like to
improve the answers, if you want. Actually, it would be kind of neat to
have that in numpy or scipy...
What are you trying to do? Show us the code, and I'm sure someone can
explain why you are getting what you are getting.
Christopher Barker, Ph.D.
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
More information about the Numpy-discussion