haskell / mwc-random

A very fast Haskell library for generating high quality pseudo-random numbers.
http://hackage.haskell.org/package/mwc-random
BSD 2-Clause "Simplified" License
54 stars 25 forks source link

uniform equivilent to System.Random.randoms and randomRs #69

Closed WeeBull closed 5 years ago

WeeBull commented 5 years ago

I'm porting some code from using System.Random to this library. The code is using randoms and randomRs functions which produces an infinite list of random values. Is there an advised way to do the same thing here?

If not, then an alternative would be a vector, but I'd need a vector of ranged values (i.e. uniformR), but we don't seem to have that available.

Shimuuar commented 5 years ago

Unfortunately there's no way to generate infinite list since generator work in ST/IO it uses mutable state underneath.

Generating finite list/vector on other hand is easy: replicateM n (uniformR range gen)

WeeBull commented 5 years ago

Thanks, closing issue