[Numpy-discussion] numpy.mean still broken for large float32 arrays

Charles R Harris charlesr.harris at gmail.com
Thu Jul 24 12:59:38 EDT 2014


On Thu, Jul 24, 2014 at 8:27 AM, Jaime Fernández del Río <
jaime.frio at gmail.com> wrote:

> On Thu, Jul 24, 2014 at 4:56 AM, Julian Taylor <
> jtaylor.debian at googlemail.com> wrote:
>
>> In practice one of the better methods is pairwise summation that is
>>  pretty much as fast as a naive summation but has an accuracy of
>> O(logN) ulp.
>> This is the method numpy 1.9 will use this method by default (+ its
>> even a bit faster than our old implementation of the naive sum):
>> https://github.com/numpy/numpy/pull/3685
>>
>> but it has some limitations, it is limited to blocks fo the buffer
>> size (8192 elements by default) and does not work along the slow axes
>> due to limitations in the numpy iterator.
>>
>
> For what it's worth, I see the issue on a 64-bit Windows numpy 1.8, but
> cannot on a 32-bit Windows numpy master:
>
> >>> np.__version__
> '1.8.0'
> >>> np.ones(100000000, dtype=np.float32).mean()
> 0.16777216
>
> >>> np.__version__
> '1.10.0.dev-Unknown'
> >>> np.ones(100000000, dtype=np.float32).mean()
> 1.0
>
>
Interesting. Might be compiler related as there are many choices for
floating point instructions/registers in i386. The i386 version may
effectively  be working in double precision.

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20140724/5a746de8/attachment.html>


More information about the NumPy-Discussion mailing list