[Numpy-discussion] please change mean to use dtype=float
Tim Hochberg
tim.hochberg at ieee.org
Fri Sep 22 15:18:07 EDT 2006
Charles R Harris wrote:
[CHOP]
> On 9/22/06, *Tim Hochberg* <tim.hochberg at ieee.org
> <mailto:tim.hochberg at ieee.org>> wrote:
>
>
> It sounds like there is some consensus to do something to improve the
> precision after 1.0 comes out. I don't think the details are entirely
> nailed down, but it sounds like some combination of using Kahan
> summation and increasing the minimum precision of the accumulator is
> likely for sum, mean, var and std.
>
>
> I would go with double as the default except when the base precision
> is greater. Higher precisions should be available as a check, i.e., if
> the results look funny use Kahan or extended to see if roundoff is a
> problem. I think Kahan should be available because it adds precision
> to *any* base precision, even extended or quad, so there is always
> something to check against. But I don't think Kahan should be the
> default because of the speed hit.
>
Note that add.reduce will be available for doing simple-fast-reductions,
so I consider some speed hit as acceptable. I'll be interested to see
what the actual speed difference between Kahan and straight summation
actually are. It may also be possible to unroll the core loop cleverly
so that multiple ops can be scheduled on the FPU in parallel. It doesn't
look like naive unrolling will work since each iteration depends on the
values of the previous one. However, it probably doesn't matter much
where the low order bits get added back in, so there's some flexibility
in how the loop gets unrolled.
-tim
PS. Sorry about the untrimmed posts.
More information about the NumPy-Discussion
mailing list