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

Phil Steitz resolved MATH-724.
------------------------------

    Resolution: Fixed

Thanks for reporting and diagnosing this, Dennis.

Slightly modified version of the third patch (just removing unecessary parens), 
along with tests, committed in r1221490.  The "negativeToPositiveRange" tests 
fail before the fix.  The change to nextUniform is also needed to prevent 
overflows. I changed the relevant test cases to use the TestUtils chisquare 
test, which is more straightforward and has better output.  This was added 
after the original versions of these tests were written.  Others in this class 
should be similarly updated.  Patches welcome to further tidy the tests, but 
this issue can be resolved.
                
> 1
> -
>
>                 Key: MATH-724
>                 URL: https://issues.apache.org/jira/browse/MATH-724
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 1.0, 1.1, 1.2, 2.0, 2.1, 2.2
>            Reporter: Dennis Hendriks
>             Fix For: 3.0
>
>         Attachments: NextIntTest3.java, NextIntUniformTest.java, 
> NextUniformTest3.java, math-724-v2.patch, math-724-v3.patch, math-724.patch
>
>
> When using the RandomDataImpl.nextInt function to get a uniform sample in a 
> [lower, upper] interval, when the lower value is less than zero, the output 
> is not uniformly distributed, as the lowest value is practically never 
> returned.
> See the attached NextIntUniformTest.java file. It uses a [-3, 5] interval. 
> For several values between 0 and 1, testNextIntUniform1 prints the return 
> value of RandomDataImpl.nextInt (as double and as int). We see that -2 
> through 5 are returned several times. The -3 value however, is only returned 
> for 0.0, and is thus under-respresented in the integer samples. The output of 
> test method testNextIntUniform2 also clearly shows that value -3 is never 
> sampled.

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

        

Reply via email to