Re: [Numpy-discussion] numpy.mean still broken for largefloat32arrays
Thanks for the clarification, but how is the numpy rounding directed? Round to nearest, ties to even? http://en.wikipedia.org/wiki/IEEE_floating_point#Rounding_rules Just curious, as I couldn't find a reference. - Ray At 07:44 AM 7/27/2014, you wrote:
On Sun, Jul 27, 2014 at 3:16 PM, RayS
wrote: At 02:04 AM 7/27/2014, you wrote:
You won't be able to do it by accident or omission or a lack of discipline. It's not a tempting public target like, say, np.seterr().
BTW, why not throw an overflow error in the large float32 sum() case? Is it too expensive to check while accumulating?
In the example that started this thread, there's no overflow (in the technical sense) occurring. Overflow for ints means wrapping around, and for floats it means exceeding the maximum possible value and overflowing to infinity.
The problem here is that when summing up the values, the sum gets large enough that after rounding, x + 1 = x and the sum stops increasing. (For float32's all this requires is x > 16777216.) So while the final error is massive, the mechanism is just ordinary floating-point round-off error.
-n
-- Nathaniel J. Smith Postdoctoral researcher - Informatics - University of Edinburgh http://vorpus.org _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
participants (1)
-
RayS