[Haskell-cafe] statistics package and randomness

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


On Mon, Oct 12, 2009 at 12:25 AM, Michael Mossey <mpm at alumni.caltech.edu>wrote:

> I'm trying to learn how to use randomness in Haskell and it seems very
> non-straightforward and complex. I could do a lot of things using 'split'
> from System.Random, but apparently it's broken. There is the statistics
> package here:
>
> http://hackage.haskell.org/package/statistics
>
> Is this a better solution?
>

Yes, as it's much faster, more robust, and (depending on your perspective)
easier to use, provided you understand the ST monad.


> It uses the ST monad in the RandomVariate module. Can someone point me to a
> tutorial explaining ST, and/or a tutorial in the RandomVariate module?
>

For a tutorial on grokking ST, I'd suggest chapter 26 of Real World Haskell,
but I'm biased, since I wrote it:

http://book.realworldhaskell.org/read/advanced-library-design-building-a-bloom-filter.html

Note that this already assumes that you understand monads pretty well.

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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091012/b8766d1d/attachment.html


More information about the Haskell-Cafe mailing list