Return-Path: X-Original-To: apmail-commons-issues-archive@minotaur.apache.org Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 29F0E1886C for ; Mon, 21 Dec 2015 00:42:48 +0000 (UTC) Received: (qmail 76271 invoked by uid 500); 21 Dec 2015 00:42:47 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 76175 invoked by uid 500); 21 Dec 2015 00:42:47 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 76159 invoked by uid 99); 21 Dec 2015 00:42:46 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 21 Dec 2015 00:42:46 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id B31722C1F57 for ; Mon, 21 Dec 2015 00:42:46 +0000 (UTC) Date: Mon, 21 Dec 2015 00:42:46 +0000 (UTC) From: "Gilles (JIRA)" To: issues@commons.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (MATH-1300) BitsStreamGenerator#nextBytes(byte[]) is wrong MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/MATH-1300?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15065947#comment-15065947 ] Gilles commented on MATH-1300: ------------------------------ bq. It's nice to know that running the same simulation with the same seed always produces the same result. As Phil noted, CM abides by this. The question was whether _different_ implementations should produce the exact same sequence. In this case, if the reference also contained the sometimes redundant call, then fixing it in CM would consequently make its sequences differ from the reference. > 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)