I've been meaning to get back to you about your proposal for some time.
I have had thoughts along these lines for a while now, and I like the
looks of this proposal. A few things I would add are:
1) capability to add other types of IRNG's that produce 48-bit or 64-bit
integers for use in RNG's
2) Gaussian and K-V type distributions as RNG's
3) RNG's should be "expression-enabled" so that they can act like scalars
of their return type in an expression (this could be done externally)
4) the ability to "skip ahead" by N numbers in a random sequence, hopefully
in a way that is faster than just producing the next N numbers of the sequence
This last item is useful for cases where you wish to distribute segments
of a random number sequence across multiple processors. This is critical
to reproducibility in parallel applications. Also, I'm not sure how your
"sharedState" would work in a parallel or multithreaded environment.
Julian C.
P.S. We are looking at providing a POOMA interface to the SPRNG library
from NCSA. We should make sure that this new RNG interface could work as
a wrapper around the generators that SPRNG offers. I think we can do that.
On Feb 11, 7:48pm, tveldhui wrote:
> Subject: random number generators
> Hi folks, I've been working on random number generators
> lately. I've kept the RNG code separate from Blitz++
> proper, in the hope that POOMA, MTL, SL++, A++/P++ etc. people
> could use and contribute to the same library -- it is the sort
> of thing we all need, and of course standardization is a Good Thing.
>
> I'm attaching a sketch of the design, and there are user
> documents at
> http://seurat.uwaterloo.ca/blitz/manual/blitz08.html
>
> I am flexible on the design, namespace, etc. I am floating this
> as a proposal for discussion and would be happy to modify it to
> suit everyone's needs. I volunteer to maintain the code and
> incorporate patches if everyone is agreeable.
>
> Design sketch:
>
> There are two types of generators:
> Integer RNGs: provide uniformly distributed, unsigned 32 bit integers.
> RNGs: use Integer RNGs (IRNGs) to provide other distributions.
>
> The default IRNG is Matsumoto and Nishimura's "Mersenne Twister"
> MT19937, which has a period of 2^19937-1 (i.e. it will never repeat).
> This generator has passed lots of stringent tests, including the
> Diehard suite.
>
> These RNGs are included now:
> Uniform: uniform on [0,1) (the default)
> UniformClosedOpen: uniform on [0,1)
> UniformClosed: uniform on [0,1]
> UniformOpen: uniform on (0,1)
> UniformOpenClosed: uniform on (0,1]
> NormalUnit: normal with zero mean, unit variance
> Normal: normal with specified mean and variance
> ExponentialUnit: exponential with unit variance
> Exponential: exponential with specified variance
> F: F distribution
> Beta: Beta distribution
> ChiSquare: Chi Square distribution
> Gamma: Gamma distribution
> DiscreteUniform Discrete uniform on 0..N-1
>
> Others will be added as time allows.
>
> RNGs take three template parameters (there are defaults for
> all three). As an example,
>
> Uniform<T, IRNG, stateTag>
> T: type of random number to generate (float, double, or long double
> for continuous distributions).
> Note that double + long double are slower to generate, because filling
> the entire mantissa with random bits requires several random integers.
> Default is float.
> IRNG: underlying Integer RNG to use. Default is MersenneTwister.
> stateTag: either sharedState or independentState. If sharedState, the
> IRNG is shared with other generators. If independentState,
> this RNG contains its own IRNG. The default is sharedState.
>
> RNGs have these methods:
>
> T random(); returns a random number
> void seed(unsigned int) seeds the IRNG
>
> Plus others to set mean, variance and other parameters.
>
>-- End of excerpt from tveldhui
-- Julian C. Cummings Advanced Computing Laboratory Los Alamos National Laboratory (505) 667-6064 julianc@acl.lanl.gov