Re: [Numpy-discussion] numpy.random.multinomial() cannot handle zero's

2007-08-28 Thread Stefan van der Walt
On Mon, Aug 27, 2007 at 04:54:21PM -0700, Christopher Barker wrote: > Stefan van der Walt wrote: > > but using the Pyrex module, it yields true. You can find the code at > > > > http://mentat.za.net/html/refer/somesumbug.tar.bz2 > > That link appears to be broken. Sorry, http://mentat.za.net/re

Re: [Numpy-discussion] numpy.random.multinomial() cannot handle zero's

2007-08-27 Thread Lino Mastrodomenico
2007/8/28, Stefan van der Walt <[EMAIL PROTECTED]>: > I find this behaviour odd for addition. Under python: > > In [7]: 0.8+0.2 > 1.0 > Out[7]: False Keep in mind that both 0.2 and 0.8 cannot be represented exactly as floating-point numbers (unless you use decimal floating points, like the "decim

Re: [Numpy-discussion] numpy.random.multinomial() cannot handle zero's

2007-08-27 Thread Lino Mastrodomenico
2007/8/28, Christopher Barker <[EMAIL PROTECTED]>: > Stefan van der Walt wrote: > > but using the Pyrex module, it yields true. You can find the code at > > > > http://mentat.za.net/html/refer/somesumbug.tar.bz2 > > That link appears to be broken. The correct one is probably: http://mentat.z

Re: [Numpy-discussion] numpy.random.multinomial() cannot handle zero's

2007-08-27 Thread Christopher Barker
Stefan van der Walt wrote: > but using the Pyrex module, it yields true. You can find the code at > > http://mentat.za.net/html/refer/somesumbug.tar.bz2 That link appears to be broken. -Chris -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/OR&R(2

Re: [Numpy-discussion] numpy.random.multinomial() cannot handle zero's

2007-08-27 Thread Christopher Barker
Stefan van der Walt wrote: > I find this behaviour odd for addition. Under python: > > In [7]: 0.8+0.2 > 1.0 > Out[7]: False > > but using the Pyrex module, it yields true. odd. I wonder if one is using extended floating point in the FPU, and the other not? What hardware/OS/compiler are you us

Re: [Numpy-discussion] numpy.random.multinomial() cannot handle zero's

2007-08-27 Thread Stefan van der Walt
Hi Chris On Mon, Aug 27, 2007 at 11:07:00AM -0700, Christopher Barker wrote: > 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

Re: [Numpy-discussion] numpy.random.multinomial() cannot handle zero's

2007-08-27 Thread Christopher Barker
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 "

Re: [Numpy-discussion] numpy.random.multinomial() cannot handle zero's

2007-08-26 Thread Stefan van der Walt
Hi Michael On Sun, Aug 26, 2007 at 01:45:55PM +0100, Michael Nandris wrote: > Is there an easy way around this problem, that does not involve fixing the API > (like using NaN instead of 0.0)? > > >>> from numpy.random import multinomial > >>> multinomial(100,[ 0.2, 0.4, 0.1, 0.3 ]) > array([19, 4

[Numpy-discussion] numpy.random.multinomial() cannot handle zero's

2007-08-26 Thread Michael Nandris
Hi, Is there an easy way around this problem, that does not involve fixing the API (like using NaN instead of 0.0)? >>> from numpy.random import multinomial >>> multinomial(100,[ 0.2, 0.4, 0.1, 0.3 ]) array([19, 45, 10, 26]) >>> multinomial( 100, [0.2, 0.0, 0.8, 0.0] ) Traceback (most recent cal