I have a Java simulation in which I need to use Uniform, Exponential, Poisson, and Gamma distributions - and I need to initialize the random stream and/or each of these distributions with the same seed (so that I can exactly reproduce a trajectory given a fixed seed).
I am using Parallel Colt (which is a multithreaded version of Colt).
For Uniform, I could properly seed a DoubleUniform object (after importing from cern.jet.random.tdouble.DoubleUniform) as:
int fixedSeed = 12345;
doubleUniformDist = new DoubleUniform (0.0, 1.0, fixedSeed);
However, for Exponential, Poisson, and Gamma distributions (all in cern.jet.random.tdouble), I cannot do the same by passing the fixedSeed - because they expect a DoubleRandomEngine object to be passed:
Constructor Summary
Exponential(double lambda, DoubleRandomEngine randomGenerator)
Constructs a Negative Exponential distribution.
Poisson(double mean, DoubleRandomEngine randomGenerator)
Constructs a poisson distribution.
Gamma(double alpha, double lambda, DoubleRandomEngine randomGenerator)
Constructs a Gamma distribution.
Is there a way to initialize these (Exponential, Poisson, and Gamma) the same way as I did with Uniform? Or should I instantiate a parent/base class (if so, how?) in cern.jet.random.tdouble from which all these classes have been extended?
Notes:
- Again, I'd like to have a single random stream (so that all my distributions could use random numbers from that stream) - this is very important for reproducibility.
- An example simulation may need to sample these distributions millions of times (in total) - so performance/speed is always an issue.
It looks like
DoubleMersenneTwister, which extends DoubleRandomEngine, allows you to set a seed in its constructor.