[Numpy-discussion] problem with poisson generators

Flavio Coelho fccoelho at gmail.com
Thu Jul 14 00:19:26 CDT 2005


2005/7/13, David M. Cooke <cookedm at physics.mcmaster.ca>:
> 
> On Tue, Jul 12, 2005 at 05:32:25PM -0300, 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?
> 
> This looks like bug #1123145 in Numeric:
> 
> 
> http://sourceforge.net/tracker/index.php?func=detail&aid=1123145&group_id=1369&atid=101369
> 
> which was fixed a few months ago. numarray, I believe, originally took
> ranlib.c from Numeric, so it doesn't have this bug fix. Try replacing
> numarray's ranlib.c with the version from Numeric 24.0b2 (or CVS).



I have both numeric 23.7 and numarray 1.3.1 installed and on neither of them 
I could reproduce the bug when I called them directly from the python 
interpreter. However they fail on mean 0.0 every time when called within my 
code. So it appears to me that the Bug you mentioned is not what is causing 
my problem. It seems to stem from interaction with the way its being called, 
maybe some carryover from previous calls...
this is the test I ran on the interpreter:
[(poisson(i),i) for i in uniform(-20,20,1000) if i<=0] 

I also ran:

sum(poisson(0,100000))

they both worked flawlessly. In the first test I wanted to see if there was 
some carry over from previous runs when called with various means (which is 
closer to the way it is used within my code), but it returned zero every 
time. (I don't use negative means in my code, but I wanted to try it here 
just in case)

--
> |>|\/|<
> 
> /--------------------------------------------------------------------------\
> |David M. Cooke http://arbutus.physics.mcmaster.ca/dmc/
> |cookedm at physics.mcmaster.ca <http://physics.mcmaster.ca>
> 



-- 
Flávio Codeço Coelho
registered Linux user # 386432
---------------------------
Great spirits have always found violent opposition from mediocrities. The
latter cannot understand it when a man does not thoughtlessly submit to
hereditary prejudices but honestly and courageously uses his intelligence.
Albert Einstein
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20050714/03d499f2/attachment.html 


More information about the Numpy-discussion mailing list