[Numpy-discussion] Floating Point Difference between numpy and numarray

Matthieu Brucher matthieu.brucher@gmail....
Wed Sep 3 05:47:49 CDT 2008


By default, numpy uses float64, but you told it to use float32 ;)

Matthieu

2008/9/3, Hanni Ali <hanni.ali@gmail.com>:
> Also can you think of a way either dtype is always float64? I have a lot of
> functions and to add dtype='float64' would require *loads* of testing,
> whereas if I can set it centrally on the matrix or in the environment that
> would be so much easier.
>
> Hanni
>
>
> 2008/9/3 Hanni Ali <hanni.ali@gmail.com>
> >
> > Sebastian you legend, that seems to be it.
> >
> >
> > Thank you very much.
> >
> > >>> matrix.mean(dtype='float64')
> > 0.41582015156745911
> >
> > What seems odd is that numpy doesn't do this on it's own...
> >
> >
> >
> >
> > 2008/9/3 Sebastian Stephan Berg <sebastian@sipsolutions.net>
> >
> >
> >
> >
> > > Hi,
> > >
> > > just guessing here. But numarray seems to calculate the result in a
> > > bigger dataype, while numpy uses float32 which is the input arrays size
> > > (at least I thought so, trying it confused me right now ...). In any
> > > case, maybe the difference will be gone if you
> > > use .mean(dtype='float64') (or whatever dtype numarray actually uses,
> > > which seems to be "numarray.MaximumType(a.type())"
> where a is the array
> > > to take the mean).
> > >
> > > Sebastian
> > >
> > >
> > >
> > >
> > > _______________________________________________
> > > Numpy-discussion mailing list
> > > Numpy-discussion@scipy.org
> > >
> http://projects.scipy.org/mailman/listinfo/numpy-discussion
> > >
> >
> >
>
>
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion@scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion
>
>


-- 
French PhD student
Information System Engineer
Website: http://matthieu-brucher.developpez.com/
Blogs: http://matt.eifelle.com and http://blog.developpez.com/?blog=92
LinkedIn: http://www.linkedin.com/in/matthieubrucher


More information about the Numpy-discussion mailing list