commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Phil Steitz <phil.ste...@gmail.com>
Subject Re: [math] Making PRNG pluggable in o.a.c.m.random classes
Date Sun, 22 May 2005 21:30:59 GMT
Thanks, Brent.
As I write up the docs, I am thinking about adding one more thing,
which I would apprecate feedback on.  I mentioned above that the
RandomGenerator / AbstractRandomGenerator provided a generic facility
for replacing java.util.random.  Recompilation is still required,
however, to use this.  I am thinking now that it might be useful to
add a class that *extends* java.util.Random to wrap a RandomGenerator
to make it possible to do this in a binary compatible way.  Does this
make sense?

Phil

On 5/21/05, Brent Worden <brent@worden.org> wrote:
> The implementation looks good an a lot less heftier than what I was
> anticipating.
> 
> Good work,
> 
> Brent Worden
> 
> > -----Original Message-----
> > From: Phil Steitz [mailto:phil.steitz@gmail.com]
> > Sent: Sunday, May 15, 2005 1:39 PM
> > To: Jakarta Commons Developers List
> > Subject: Re: [math] Making PRNG pluggable in o.a.c.m.random classes
> >
> > I committed the changes described above.  Feedback welcome.
> > I tested adapting and integration a RngPack generator.
> > Adaptor for Mersenne Twister looks like this (base adaptor
> > for all RngPack generators would be similar):
> >
> > /**
> >  * AbstractRandomGenerator based on RngPack RanMT generator.
> >  */
> > public class TestRngPackGenerator extends AbstractRandomGenerator {
> >
> >     private RanMT random = new RanMT();
> >
> >     public void setSeed(long seed) {
> >        random = new RanMT(seed);
> >     }
> >
> >     public double nextDouble() {
> >         return random.raw();
> >     }
> >
> >     public double nextGaussian() {
> >         return random.gaussian();
> >     }
> >
> >     public int nextInt(int n) {
> >         return random.choose(n);
> >     }
> >
> >     public boolean nextBoolean() {
> >         return random.coin();
> >     }
> > }
> >
> > I will update the user guide to include this and other
> > examples assuming all are OK with these changes.
> >
> > Phil
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message