From: Topher Cooper (topher_at_[hidden])
Date: 2004-07-09 13:35:26
On Thursday, July 8, 2004, at 11:44 AM, Anders Edin wrote:
> // For me it would seem more natural if the engine class would be a
> // singleton, so that there can be only one object of any particular
> // random generator engine type.
> // Our purpose for using random numbers is to simulate physical
> // I can't think of a case when there would be a need for several
> // engines, even if there can of course be many different random
> // distributions in an application.
> // Having the same random number sequence in different parts of a
> // can probably create very strange behaviour, since the numbers from
> // different engines of the same type will be perfectly correlated.
> // Perhaps other applications have use of several random engines?
One of the important characteristics of a pseudo random number
generator is, oddly enough, determinancy. Given the same seed, you get
the same sequence and can therefore reproduce the exact same results.
This allows results to be checked and bugs to be tracked down reliably.
If another thread, or just a library used by your application (for
example, something that uses a pseudo-random numbers for dithering a
graphic display), was using the same singleton engine as your
application this characteristic would be lost. The number of values
drawn by the other parts of your system might change or reseeding of
the engine might happen without your knowledge.
No serious statistical, scientific, or simulation results should ever
be done using any kind of shared state RNG (including the C stdlib rand
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk