[erlang-questions] Implementation of a 2006 version of Wichmann-Hill random number generator for Erlang/OTP

Kenji Rikitake <>
Wed Dec 1 01:38:11 CET 2010


In the message <>
dated Wed, Dec 01, 2010 at 09:09:05AM +0900,
Kenji Rikitake <> writes:
> * seed elements: old 3, new 4, as Robert pointed out.

The random module has
seed/0, 
seed/1 with an argument of a 3-element tuple,
and
seed/3.

new ran() type will be a 4-element tuple.  Anything dependent of the
assumption that ran() is a 3-element tuple will break.

Adding seed/4 will not break the backward compatibility.

Maybe additional code for handling
seed({A1, A2, A3}) and seed({A1, A2, A3, A4}) in
the seed/1 needed?

>   I don't have an idea about generating two elements from one.

A crude implementation is: 
  seed({B1, B2, B3}) -> seed({B1, B2, B3, B3}).
  (or seed(B1, B2, B3, B3))

Regards,
Kenji Rikitake

> In the message <>
> dated Tue, Nov 30, 2010 at 10:50:11PM +0000,
> Robert Virding <> writes:
> > What would be nice is if we could just drop the new algorithm into the old module so we avoid having to have 2 random modules. As I see it the main problem is that the old random has 3 seeds while the new has 4, which makes the seed functions incompatible. Couldn't you just have one seed be two?
> > 
> > It would mean that the "new" random would return better values, but they would be different from what the "old" random returned. I don't see this as a problem but others might.
> > 
> > Robert
> 
> > > > > The 2006 Wichmann-Hill RNG for Erlang moved to
> > > > > https://gist.github.com/713144
> > > > > under the name of
> > > > > random_wh06.erl


More information about the erlang-questions mailing list