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

Alex D Herbert commented on RNG-19:
-----------------------------------

Just trying some variations...

With a constructor:
{code:java}
Random random = ...;
UniformRandomProvider rng = new JDKRandomWrapper(random);

// Use Adaptor as per math4
UniformRandomProvider rng = new JDKRandomAdaptor(random);
{code}
Or a factory class without the Utils suffix:
{code:java}
Random random = ...;
UniformRandomProvider rng = Randoms.asUniformRandomProvider(random);
{code}
A factory class could be the entry point for conversions allowing the reverse:
{code:java}
UniformRandomProvider rng = ...;
Random random = Randoms.asRandom(rng);
{code}
This factory therefore allows to/from conversions between the Java random API 
and the Commons RNG API.

The second method is helpful if you already have a UniformRandomProvider and 
want to use it in for example:
{code:java}
Collections.shuffle(List<?>, Random)
{code}

Without adding the commons-sampling dependency for ListSampler::shuffle. I do 
not know other JDK locations that require Random but 3rd party libraries would 
likely use Random as the common API.

> System generator (/dev/random)
> ------------------------------
>
>                 Key: RNG-19
>                 URL: https://issues.apache.org/jira/browse/RNG-19
>             Project: Commons RNG
>          Issue Type: Wish
>            Reporter: Emmanuel Bourg
>            Priority: Minor
>
> Commons RNG could include a random number generator based on the output of 
> /dev/random or /dev/urandom on Unix systems.
> Commons Crypto has an implementation that could be used as a starting point:
> https://github.com/apache/commons-crypto/blob/master/src/main/java/org/apache/commons/crypto/random/OsCryptoRandom.java



--
This message was sent by Atlassian Jira
(v8.3.2#803003)

Reply via email to