[Haskell-cafe] You are in a twisty maze of concurrency libraries,
all different ...
bos at serpentine.com
Fri Dec 4 18:30:44 EST 2009
On Fri, Dec 4, 2009 at 7:38 AM, Duncan Coutts
<duncan.coutts at 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
- 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
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.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe