[Numpy-discussion] numpy.random.multinomial() cannot handle zero's
Christopher Barker
Chris.Barker@noaa....
Mon Aug 27 13:07:00 CDT 2007
Stefan van der Walt wrote:
> For some reason, the kahan_sum of [0.2,0.0,0.8,0.0] is ever so
> slightly larger than 1.0 (in the order of 1e-16), but I'm not sure
> why, yet (this isn't specific to kahan summation -- normal summation
> shows the same behavior).
Just to make sure -- is the khan_sum "compensated summation"?
Is the kahan_sum closer? -- it should be, though compensated summation
is really for adding LOTS of numbers, for 4, it's pointless at best.
Anyway, binary floating point has its errors, and compensated summation
can help, but it's still not exact for numbers that can't be exactly
represented by binary.
i.e. if your result is within 15 decimal digits of the exact result,
that's as good as it gets.
-Chris
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker@noaa.gov
More information about the Numpy-discussion
mailing list