[erlang-questions] Random behaviour

Kenji Rikitake <>
Tue Sep 7 16:35:14 CEST 2010


In the message <>
dated Tue, Sep 07, 2010 at 03:54:26PM +0200,
Olivier BOUDEVILLE <> writes:
> Shouldn't the link read "http://github.com/jj1bdx/sfmt-erlang" ?

You are right. My mistake.

> By the way, regarding that seeding: how could it be performed reliably 
> without the crypto module? I believe that crypto needs libssl which may 
> not be available on some platforms. Any idea?

/dev/random either on Linux or on FreeBSD will work as (at least
practically) a reliable seeder, though I suggest crypto:rand_bytes/1
(with OpenSSL).

> On a side note, maybe a neat addition around sfmt would be to provide a 
> function which performs an efficient uniform shuffle of a user-specified 
> list (linked to the "Speedy unsort" discussion, 
> http://groups.google.com/group/erlang-programming/browse_thread/thread/ff5c9d88f78e2456). 
> Unless it would be too far stretched from the purpose of such a library?

I remember the discussion, though I don't really recall the shuffling
algorithm itself now.  SFMT is basically a 32bit integer PRNG so you can
use it for whatever you want.  sfmt:gen_rand32_max/1 will be helpful
(generating the integer sequence between 0 to N-1)

Regards,
Kenji Rikitake


More information about the erlang-questions mailing list