[Haskell-beginners] randmomR produces only even values

Chaddaï Fouché chaddai.fouche at gmail.com
Sat Nov 7 17:17:23 UTC 2015


The System.Random is just not very good, you should not use it if you need
something fast or cryptographically secure... But as a first choice for
just a few random numbers it's good enough and it was chosen specifically
for its capability to split a generator into two, so that's probably what
you should be using if you're going to do simulations in parallel with
System.Random. Or use random seeds at least !
This is specifically an interaction between random*R* and mkStdGen with low
seeds (random don't seem to have this particular flaw), since we're still
using a pseudo-random generator, we ought to be pretty careful in the way
we use it (those have always been touchy beasts) and this particular usage
seems to be a bad counter-example of what to do with a PRNG.

If we can improve System.Random to avoid this particular misbehavior we
should but using a PRNG in this fashion and hoping for good randomness from
the result is probably a bad idea in the first place.

Le mer. 4 nov. 2015 à 11:00, Dominic Steinitz <dominic at steinitz.org> a
écrit :

> > http://article.gmane.org/gmane.comp.lang.haskell.beginners/15925
>
> I do think this is a flaw and catches many people out despite apparently
> being well documented. And it's something one probably wants e.g. to run
> multiple Markov Chain Monte Carlo simulations in parallel.
>
> Some further information here:
> https://github.com/haskell/random/issues/30#issuecomment-153647055
>
> Dominic
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20151107/882321c8/attachment.html>


More information about the Beginners mailing list