You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Phil Steitz (JIRA)" <ji...@apache.org> on 2010/04/14 02:21:50 UTC

[jira] Closed: (MATH-294) RandomDataImpl.nextPoisson fails for means in range 6.0 - 19.99

     [ https://issues.apache.org/jira/browse/MATH-294?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Phil Steitz closed MATH-294.
----------------------------


> RandomDataImpl.nextPoisson fails for means in range 6.0 - 19.99
> ---------------------------------------------------------------
>
>                 Key: MATH-294
>                 URL: https://issues.apache.org/jira/browse/MATH-294
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 1.2, 2.0
>         Environment: Java 1.6 on mac osX
>            Reporter: Jason McFall
>             Fix For: 2.1
>
>         Attachments: math-294.patch
>
>
> math.random.RandomDataImpl.nextPoisson(double mean) fails frequently (but not always) for values of mean between 6.0 and 19.99 inclusive. For values below 6.0 (where I see there is a branch in the logic) and above 20.0 it seems to be okay (though I've only randomly sampled the space and run a million trials for the values I've tried)
> When it fails, the exception is as follows (this for a mean of 6.0)
> org.apache.commons.math.MathRuntimeException$4: must have n >= 0 for n!, got n = -2
> 	at org.apache.commons.math.MathRuntimeException.createIllegalArgumentException(MathRuntimeException.java:282)
> 	at org.apache.commons.math.util.MathUtils.factorialLog(MathUtils.java:561)
> 	at org.apache.commons.math.random.RandomDataImpl.nextPoisson(RandomDataImpl.java:434) 
> ie MathUtils.factorialLog is being called with a negative input
> To reproduce:
>     JDKRandomGenerator random = new JDKRandomGenerator();
>     random.setSeed(123456);
>     RandomData randomData = new RandomDataImpl(random);
>     for (int i=0; i< 1000000; i++){
>         randomData.nextPoisson(6.0);
>     }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira