commons-issues mailing list archives

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

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

Gilles commented on MATH-701:
-----------------------------

* Harmony:
{code}
seed = System.currentTimeMillis() + hashCode();
{code}

* I'd also prefer setting both RNGs at construction.
A user would have to write
{code}
SecureRandom secRand = SecureRandom.getInstance(algorithm, provider);
{code}
in his application's code, and that would make it clearer for him why and how an exception
can be generated (and that CM's code is not the cause of it).

* I also favour a new "SecureRandomDataImpl" as a subclass of "RandomDataImpl"; the constructor
would be something like:
{code}
public SecureRandomDataImpl(SecureRandom rng) {
    super(rng);
}
{code}
This would ensure that _all_ the {{next...}} methods use a secure RNG, whereas currently only
some of the accessors have a secure alternative (e.g. "nextGaussian" is not using "secRand").
This would be less confusing without requiring long explanations...

                
> 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