commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Phil Steitz (Commented) (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (MATH-701) Seeding a default RNG
Date Fri, 04 Nov 2011 02:45:32 GMT

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

Phil Steitz commented on MATH-701:
----------------------------------

+1 to changing the default in the RandomDataImpl to a Well generator (documenting this)
+1 as well to trying to find a better default seed (documenting how it works).  Harmony still
belongs to us, so we can certainly look at / imitate the impl there.

The reason that the argumentless constructor exists is to allow users to accept the default
generator. The lazy initialization idiom was chosen because in some cases, users may choose
to invoke the setter instead of passing a generator as a constructor argument.  This is an
older style no longer in use much in [math].  I would be OK getting rid of this - i.e., having
the argumentless constructor take the hit to create a default instance.

-0 for separating out the secure stuff.  RandomDataImpl is an aggregate class that bundles
a lot of commonly used random data generation methods.  Just as the random generator is pluggable,
so is the secure random generator, which makes the class convenient to use for applications
that require both kinds of random values.  I think its simpler and more convenient to bundle
things as they are.  Of course, I have been using this class for a long time, so I may not
be the best judge of what is simplest / easiest to use.
                
> Seeding a default RNG
> ---------------------
>
>                 Key: MATH-701
>                 URL: https://issues.apache.org/jira/browse/MATH-701
>             Project: Commons Math
>          Issue Type: Bug
>            Reporter: Gilles
>            Assignee: Gilles
>             Fix For: 3.0
>
>
> In "RandomDataImpl":
> {code}
> private RandomGenerator getRan() {
>     if (rand == null) {
>         rand = new JDKRandomGenerator();
>         rand.setSeed(System.currentTimeMillis());
>     }
>     return rand;
> }
> {code}
> The conditional branch is used by "sample()" in "AbstractContinuousDistribution".
> When several "...Distribution" objects are instantiated in a short time interval, they
are seeded with the same value.

--
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

        

Mime
View raw message