[Haskell-cafe] statistics package and randomness

Bryan O'Sullivan bos at serpentine.com
Mon Oct 12 14:05:03 EDT 2009


On Mon, Oct 12, 2009 at 11:01 AM, Bryan O'Sullivan <bos at serpentine.com>wrote:

>
> Pseudorandomness seems like one case where it would just be a hell of a lot
>> simpler to have a global generator--never split the state. Is the ST monad
>> some way to accomplish this?
>
>
> Having [...]
>

Feh, gmail fail.

Having a global generator is not actually a good thing, since it has to live
*somewhere*. If you keep its existence implicit, it becomes slow, since you
have to lock it against concurrent use by multiple threads. If you make it
explicit, you have to plumb the thing all over the place by hand, which is
also nasty. The advantage of putting the PRNG in the ST monad is that you
can seed a new PRNG close to the point where you'll need it, and not need to
pass around so much state.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091012/86e66566/attachment.html


More information about the Haskell-Cafe mailing list