samedi 9 octobre 2021

Does Elixir/Erlang Random/Rand Seed need to be called on each process?

From Hashrockets blog post on "The Adventures of Generating Random Numbers in Erlang and Elixir" Dorian Karter mentions that opening and closing erl sessions allows him to reproduce the same output from the PRNG random:uniform()..

Turns out random uses the same seed by default for every VM instance.

E.G:

Session one

1> random:uniform().
0.4435846174457203

Session two

1> random:uniform().
0.4435846174457203

I can't seem to find in documentation, or my searches across the net if calling the seed methods will apply to the whole VM, or to the process that calls the seed method only.

The question: In Elixir, would you need to call the seed (for both random or rand) function per erlang process? Or does one call ~somewhere~ apply across the entire Erlang runtime?




Aucun commentaire:

Enregistrer un commentaire