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

Frédéric Bastien nouiz at nouiz.org
Thu Jul 24 13:04:43 EDT 2014


On Thu, Jul 24, 2014 at 12:59 PM, Charles R Harris <
charlesr.harris at gmail.com> wrote:

>
>
>
> 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.
>

Also note the different numpy version. Julian told that numpy 1.9 will use
a more precise version in that case. That could explain that.

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


More information about the NumPy-Discussion mailing list