commons-issues mailing list archives

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


Gilles commented on MATH-701:

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

* I'd also prefer setting both RNGs at construction.
A user would have to write
SecureRandom secRand = SecureRandom.getInstance(algorithm, provider);
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:
public SecureRandomDataImpl(SecureRandom rng) {
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:
>             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:!default.jspa
For more information on JIRA, see:


View raw message