You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Thomas Neidhart (JIRA)" <ji...@apache.org> on 2012/11/16 09:46:12 UTC

[jira] [Commented] (MATH-899) A random crash of MersenneTwister random generator

    [ https://issues.apache.org/jira/browse/MATH-899?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13498677#comment-13498677 ] 

Thomas Neidhart commented on MATH-899:
--------------------------------------

Hi,

Looking at the code, I do not understand how this can happen:

{noformat}
        if (mti >= N) { // generate N words at one time
            ...

            mti = 0;
        }

        y = mt[mti++];
{noformat}

So first we check if mti is gte to N, reset it in this case, and then use the mti value and increment afterwards.
Could it be that you use the MersenneTwister in a multi-threading environment, where the nextXXX() methods are called in a concurrent manner?
                
> A random crash of MersenneTwister random generator
> --------------------------------------------------
>
>                 Key: MATH-899
>                 URL: https://issues.apache.org/jira/browse/MATH-899
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 3.0
>         Environment: Windows 7, JDK 1.7.05
>            Reporter: Alexander Nozik
>            Priority: Minor
>
> There is a very small probability that MersenneTwister generator gives a following error: 
> java.lang.ArrayIndexOutOfBoundsException: 624
> in MersenneTwister.java line 253
> The error is completely random and its probability is about 1e-8.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira