Re: [Haskell-cafe] Mersenne-random and standard random API

2012-02-10 Thread Yves Parès
I just thought about something: basically all these APIs provides a IO [a] (where a is a randomly generable type) function. Is there a problem with the approach that is to rely on lazy evaluation to pass to pure code (either explicitely or through State) the infinite list generated in IO and

Re: [Haskell-cafe] Mersenne-random and standard random API

2012-02-10 Thread Aleksey Khudyakov
On 10.02.2012 18:38, Yves Parès wrote: I just thought about something: basically all these APIs provides a IO [a] (where a is a randomly generable type) function. Is there a problem with the approach that is to rely on lazy evaluation to pass to pure code (either explicitely or through State)

Re: [Haskell-cafe] Mersenne-random and standard random API

2012-02-10 Thread Yves Parès
It's more like Seed → [a]. IO is not really needed here. You're absolutely right. I stand corrected. 1. One may want to generate values of different types and/or distibutions. Yes, I saw this limitation before. But you can just generate one infinite list (and then one seed) per distribution,

Re: [Haskell-cafe] Mersenne-random and standard random API

2012-02-09 Thread Ertugrul Söylemez
Yves Parès yves.pa...@gmail.com wrote: I've been in the past told that mersenne-random was much better than the standard random package. This is relative. The Mersenne Twister algorithm has a large memory footprint, but in relation to the size of the average Haskell program, this is probably

Re: [Haskell-cafe] Mersenne-random and standard random API

2012-02-09 Thread Aleksey Khudyakov
On 09.02.2012 01:56, Yves Parès wrote: Hi, I've been in the past told that mersenne-random was much better than the standard random package. ... So is it possible to use the fast and efficient mersenne generator with the convenient and general random API? I think design of Random type class

Re: [Haskell-cafe] Mersenne-random and standard random API

2012-02-09 Thread Jerzy Karczmarczuk
Aleksey Khudyakov : I think design of Random type class basically precludes efficient generators with large periods and consequently large state. Look at next function: next :: g - (Int, g) It means that state has to be copied but for efficiency we want to mutate it in place. I consider

Re: [Haskell-cafe] Mersenne-random and standard random API

2012-02-09 Thread Aleksey Khudyakov
On 09.02.2012 15:32, Jerzy Karczmarczuk wrote: Aleksey Khudyakov : 1. Mersenne Twister, AND congruential generators AND the Marsaglia stuff, all use some kind of seed, all are stateful. There are no miracles. Just look the agressive monadization, the form of defaultSeed, etc. within MWC.hs,

Re: [Haskell-cafe] Mersenne-random and standard random API

2012-02-09 Thread Jerzy Karczmarczuk
Aleksey Khudyakov: On 09.02.2012 15:32, Jerzy Karczmarczuk wrote: 1. Mersenne Twister, AND congruential generators AND the Marsaglia stuff, all use some kind of seed, all are stateful. There are no miracles. Just look the agressive monadization, the form of defaultSeed, etc. within MWC.hs,

Re: [Haskell-cafe] Mersenne-random and standard random API

2012-02-09 Thread Duncan Coutts
On 9 February 2012 10:59, Aleksey Khudyakov alexey.sklad...@gmail.com wrote: So is it possible to use the fast and efficient mersenne generator with the convenient and general random API? I think design of Random type class basically precludes efficient generators with large periods and

Re: [Haskell-cafe] Mersenne-random and standard random API

2012-02-09 Thread Aleksey Khudyakov
On 09.02.2012 18:27, Duncan Coutts wrote: Actually it is not true that the state has to be copied. Using the lazy ST monad we can implement this interface and internally use mutable ST arrays. See for example

Re: [Haskell-cafe] Mersenne-random and standard random API

2012-02-09 Thread Aleksey Khudyakov
On 09.02.2012 17:28, Jerzy Karczmarczuk wrote: Aleksey Khudyakov: On 09.02.2012 15:32, Jerzy Karczmarczuk wrote: 1. Mersenne Twister, AND congruential generators AND the Marsaglia stuff, all use some kind of seed, all are stateful. There are no miracles. Just look the agressive monadization,

[Haskell-cafe] Mersenne-random and standard random API

2012-02-08 Thread Yves Parès
Hi, I've been in the past told that mersenne-random was much better than the standard random package. However, System.Random.Mersenne doesn't follow the general API described in System.Random, MTGen is not an instance of RandomGen. But a sample on System.Random.Mersenne.getStdRandom documentation