Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 2852D200B9A for ; Fri, 7 Oct 2016 14:41:31 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 26DEE160AE8; Fri, 7 Oct 2016 12:41:31 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 67C08160AD6 for ; Fri, 7 Oct 2016 14:41:30 +0200 (CEST) Received: (qmail 98885 invoked by uid 500); 7 Oct 2016 12:41:29 -0000 Mailing-List: contact dev-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Commons Developers List" Delivered-To: mailing list dev@commons.apache.org Received: (qmail 98873 invoked by uid 99); 7 Oct 2016 12:41:28 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 07 Oct 2016 12:41:28 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id 88647C0E36 for ; Fri, 7 Oct 2016 12:41:28 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 0.905 X-Spam-Level: X-Spam-Status: No, score=0.905 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SUBJ_ALL_CAPS=1.625] autolearn=disabled Authentication-Results: spamd4-us-west.apache.org (amavisd-new); dkim=pass (1024-bit key) header.d=scarlet.be Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id QpmlqFC8kly0 for ; Fri, 7 Oct 2016 12:41:26 +0000 (UTC) Received: from hel.is.scarlet.be (hel.is.scarlet.be [193.74.71.26]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTPS id 60C3B5FACD for ; Fri, 7 Oct 2016 12:41:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=scarlet.be; s=scarlet; t=1475844080; bh=YgfAGZJq5vUQfuC+g0QmdrVIwdxEmcnFp7cyxcsqLOs=; h=MIME-Version:Content-Type:Content-Transfer-Encoding:Date:From:To: Subject:In-Reply-To:References:Message-ID; b=C4+77coWe9cVuWDV9ZmPU+miH8z6qsxa9h7v6fWDAwrkwure9HLS1pmnKTbmitOpk kDOcu5BD5YKluZe/GdFKw/0HKdcuoyWXn41uWzZejoPJYNLyyLcimUr9cMoBJPGu6n ar1JveqeM3x3xfdHUBTUHq6UpZB1MecL3aQIKooQ= Received: from webmail.scarlet.be (meigs.is.scarlet.be [193.74.71.216]) by hel.is.scarlet.be (8.14.9/8.14.9) with ESMTP id u97CfJer020194 for ; Fri, 7 Oct 2016 14:41:20 +0200 X-Scarlet: d=1475844080 c=193.74.71.216 Received: from astropc12.ulb.ac.be ([164.15.138.26]) via astropc12.ulb.ac.be ([164.15.138.26]) by webmail.scarlet.be with HTTP (HTTP/1.1 POST); Fri, 07 Oct 2016 14:41:19 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Date: Fri, 07 Oct 2016 14:41:19 +0200 From: Gilles To: Subject: Re: [RNG] RNG-17 - LFG In-Reply-To: References: Message-ID: <5a7f079503a5059674219f5764568ac8@scarlet.be> X-Sender: gilles@harfang.homelinux.org User-Agent: Scarlet Webmail X-DCC-scarlet.be-Metrics: hel; whitelist X-Virus-Scanned: clamav-milter 0.98.1-exp at hel X-Virus-Status: Clean archived-at: Fri, 07 Oct 2016 12:41:31 -0000 Hello. On Thu, 6 Oct 2016 18:20:24 +0300, Artem Barger wrote: > Hi, > > > I was considering​ to give a try and implement RNG-17 > (LFG), Fine. But the Javadoc must then contain a warning akin to the one on the Wikipedia page: Marsaglia observed very poor behavior with R(24,55) and smaller generators, and advised against using generators of this type altogether. :-{ > while I'm complete a > newbie in RNG topic. Fortunately, one doesn't need to be an expert in order to port a few lines of code from C (probably) to Java. :-) But there are quite a few caveats. That's why I've added those "contribution requirements"... > So I've read a couple of tutorials and IMO I've got an > idea behind the LFG (which doesn't seem that complex). Most RNG are not complex. What is complex is to find a _simple_ code that produces sequences with the expected properties. Even more so if those properties must be provable. "Commons RNG" should not have the ambition to ship "home-made" algorithms. That's why I've added those "contribution requirements"... > > I haven't found in the literature the explanation of how to seed the > LFG > though, > e.g. I have to create first "m" slots using the seed. However I've > read in > some article, that Mersenne Twister could be used to seed the LFG. > And here > comes my first question for you, is that correct? Probably, but any procedure that produces a "sufficiently diverse" initial state would be fine. Such a procedure could be the output of another RNG. The "create" factory method does that (i.e. generates an array of length 128 filled with the output of a WELL generator) when no seed is provided. But the seed choice is a _user_ input so either (1) he does not give one (and the "create" method does its thing, as explained above), or (2) he gives one with more elements than the state actually needs, and the generator implementation should honor it (i.e. copy the seed into the state) since we assume that the user wanted the diversity of the seed he gave (no more, no less), or (3) he gives one with less elements than the state actually needs, and the implementation copies the seed to the state, and then uses a procedure to replace the remaining zeroes in the state with a more diverse contents based on the seed. > And second question I > was trying to understand how to reuse state initialization within > current > Mersenne Twister for LFG? There is a public "fillState" method in "SeedFactory" for taking care of case (3) above. I must note that I made up a simple one (for use whenever the reference code did not provide that functionality). It's a matter of convention (for "Commons RNG") but we could well prefer to use the one provided by "MersenneTwister" (which has changed since its first version), to be on the safe side... I'll open a JIRA ticket for that. > > Also I was thinking whenever it's could be beneficial to de-couple > seeding > abstraction from actual number generation? I don't follow (because I think that I did just that). Could you give an example? Regards, Gilles > > Best regards, > Artem Barger. --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org For additional commands, e-mail: dev-help@commons.apache.org