[Numpy-discussion] problem with poisson generators
Sebastian Haase
haase at msg.ucsf.edu
Tue Jul 12 14:51:55 EDT 2005
Hi Flavio!
I had reported this long time ago and this list (about numarray).
Somehow this got more or less dismissed. If I recall correctly the argument
was that nobody could reproduce it (I ran this on Debian Woody ,py2.2, (with
CVS numarray at the time).
I ended up writting my own wrapper(s):
def poissonArr(shape=defshape, mean=1):
from numarray import random_array as ra
if mean == 0:
return zeroArrF(shape)
elif mean < 0:
raise "poisson not defined for mean < 0"
else:
return ra.poisson(mean, shape).astype(na.UInt16)
def poissonize(arr):
from numarray import random_array as ra
return na.where(arr<=0, 0, ra.poisson(arr)).astype(na.UInt16)
(I use the astype(na.UInt16) because of some OpenGL code)
Just last week had this problem on a windows98 computer (python2.4).
This should get sorted out ...
Thanks for reporting this problem.
Sebastian Haase
On Tuesday 12 July 2005 13:32, Flavio Coelho wrote:
> Hi,
>
> I am having problems with the poisson random number generators of both
> Numarray and Numeric.
> I can't replicate it when calling the function from the python cosonle, but
> it has consistently malfunctioned when used within one of my scripts.
>
> What happens is that it frequently return a value greater than zero when
> called with zero mean: poisson(0.0)
>
> Unfortunately My program is too big to send attached but I have confirmed
> the malfunction by printing both the mean and the result whenever it spits
> out a wrong result.
>
> This is very weird indeed, I have run poisson millions of times by itsel on
> the python console, without any problems...
>
> I hope it is some stupid mistake, but when I replace the poisson function
> call within my program by the R equivalent command (rpois) via the rpy
> wrapper, everything works just fine...
>
> any Ideas?
More information about the NumPy-Discussion
mailing list