[ https://issues.apache.org/jira/browse/MATH-1300?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15065740#comment-15065740 ]
Gilles commented on MATH-1300: ------------------------------ But do you agree to remove the unnecessary call to "next(32)"? Or is there a standard reference (such that the RNG must reproduce the same sequence as that one for the same seed)? IMO, there is much that could be done to improve the understandability of the code (starting with the simple rule: no hard-coded numbers...). However, if there are algorithms that are superseded, I of course agree that it's not worth spending any time on them. Perhaps it is now a good opportunity to indicate in the Javadoc which RNGs are definitely obsolete (and deprecate them?) and which are recommended, so that uninformed people would not start investigating outdated code... > BitsStreamGenerator#nextBytes(byte[]) is wrong > ---------------------------------------------- > > Key: MATH-1300 > URL: https://issues.apache.org/jira/browse/MATH-1300 > Project: Commons Math > Issue Type: Bug > Affects Versions: 3.5 > Reporter: Rostislav Krasny > Attachments: MersenneTwister2.java, TestMersenneTwister.java > > > Sequential calls to the BitsStreamGenerator#nextBytes(byte[]) must generate > the same sequence of bytes, no matter by chunks of which size it was divided. > This is also how java.util.Random#nextBytes(byte[]) works. > When nextBytes(byte[]) is called with a bytes array of length multiple of 4 > it makes one unneeded call to next(int) method. This is wrong and produces an > inconsistent behavior of classes like MersenneTwister. > I made a new implementation of the BitsStreamGenerator#nextBytes(byte[]) see > attached code. -- This message was sent by Atlassian JIRA (v6.3.4#6332)