[Numpy-discussion] please change mean to use dtype=float

Sebastian Haase haase at msg.ucsf.edu
Wed Sep 20 10:47:03 CDT 2006

Robert Kern wrote:
 >> This was not supposed to be a scientific statement -- I'm (again)
 >> thinking of our students that not always appreciate the full
 >> complexity
 >> of computational numerics and data types and such.
 > They need to appreciate the complexity of computational numerics if
 > they are going to do numerical computation. Double precision does not
 > make it any simpler.

This is were we differ.

 > We haven't forgotten what newcomers will do; to the contrary, we are
 > quite aware
 > that new users need consistent behavior in order to learn how to use a
 > system.
 > Adding another special case in how dtypes implicitly convert to one
 > another will
 > impede new users being able to understand the whole system.

All I'm proposing could be summarized in:
mean(), sum(), var() ... produce output of dtype float64 (except for 
input float96 which produces float96)

A comment on this is also that for these operations the input 
type/precision is almost not related to the resulting output precision 
-- the int case makes that already clear.  (This is different for e.g. 
min() or max() )

The proposed alternative implementations seem to have one or more 
multiplication (or division) for each value -- this might be noticeably 
slower ...


More information about the Numpy-discussion mailing list