[Numpy-discussion] numpy.mean still broken for largefloat32arrays

Nathaniel Smith njs at pobox.com
Sun Jul 27 10:44:46 EDT 2014


On Sun, Jul 27, 2014 at 3:16 PM, RayS <rays at blue-cove.com> 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



More information about the NumPy-Discussion mailing list