Hi all, On 24.07.2014 11:59, Eelco Hoogendoorn wrote: > np.mean isn't broken; your understanding of floating point number is.
I am quite new to python, and this problem is discussed over and over for other languages too. However, numpy's summation problem appears with relatively small arrays already: py>import numpy as np py>np.ones((4000,4000), np.float32).mean() 1.0 py>np.ones((5000,5000), np.float32).mean() 0.67108864000000001 A 5000*5000 image is not unusual anymore today. In IDL: IDL> mean(fltarr(5000L, 5000L)+1) 1.0000000 IDL> mean(fltarr(7000L, 7000L)+1) 1.0000000 IDL> mean(fltarr(10000L, 10000L)+1) 0.67108864 I can't really explain why there are differences between the two languages (IDL uses 32-bit, single-precision, floating-point numbers) Fabien _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion