On Fri, Dec 4, 2009 at 7:38 AM, Duncan Coutts <duncan.coutts@googlemail.com> wrote:
Wait! This is not going to work!
You cannot use the MTGen from the mersenne-random in a concurrent IO
program because the C code uses a single global mutable RNG state.
So use the PRNG in the statistics package instead. It's got some nice features that make it a better choice than mersenne-random for essentially all uses:
- Faster than mersenne-random
- State is encapsulated, so you can have independent PRNGs in different threads or different library modules
- You can easily seed independent generators from your system's high-quality PRNG
It can also generate normally distributed numbers as well as uniformly distributed numbers (which is all that mersenne-random gives you), and it uses a high-quality fast algorithm for the normal distribution, rather than the usual ziggurat which is somewhat broken.