|
From: Flavio C. <fcc...@gm...> - 2005-07-14 07:16:15
|
2005/7/13, David M. Cooke <co...@ph...>: >=20 > 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,= =20 > but > > it has consistently malfunctioned when used within one of my scripts. > > > > What happens is that it frequently return a value greater than zero whe= n > > called with zero mean: poisson(0.0) > > > > Unfortunately My program is too big to send attached but I have=20 > confirmed > > the malfunction by printing both the mean and the result whenever it=20 > spits > > out a wrong result. > > > > This is very weird indeed, I have run poisson millions of times by itse= l=20 > on > > the python console, without any problems... > > > > I hope it is some stupid mistake, but when I replace the poisson=20 > function > > call within my program by the R equivalent command (rpois) via the rpy > > wrapper, everything works just fine... > > > > any Ideas? >=20 > This looks like bug #1123145 in Numeric: >=20 >=20 > http://sourceforge.net/tracker/index.php?func=3Ddetail&aid=3D1123145&grou= p_id=3D1369&atid=3D101369 >=20 > 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 the= m=20 I could reproduce the bug when I called them directly from the python=20 interpreter. However they fail on mean 0.0 every time when called within my= =20 code. So it appears to me that the Bug you mentioned is not what is causing= =20 my problem. It seems to stem from interaction with the way its being called= ,=20 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<=3D0]=20 I also ran: sum(poisson(0,100000)) they both worked flawlessly. In the first test I wanted to see if there was= =20 some carry over from previous runs when called with various means (which is= =20 closer to the way it is used within my code), but it returned zero every=20 time. (I don't use negative means in my code, but I wanted to try it here= =20 just in case) -- > |>|\/|< >=20 > /------------------------------------------------------------------------= --\ > |David M. Cooke http://arbutus.physics.mcmaster.ca/dmc/ > |co...@ph... <http://physics.mcmaster.ca> >=20 --=20 Fl=E1vio Code=E7o 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 |