From bit to a heart beat

insane innovations from a sane insanity

Thu Jun 11

A quick hack for random numbers in Erlang

It seems that you can’t get random numbers in Erlang when you are in different processes. I am building a distributed Monte Carlo simulation and I wanted two random numbers for the x and y (of the dart). So, the only way to do it (if you want it to run in a cluster) is this (at least that’s what I’ve found).

{Seed1, Seed2, Seed3} = erlang:now(),
X = random:uniform(),
random:seed(Seed1, Seed2, Seed3),
Y = random:uniform().

Any suggestions / better implementations?

Comments (View)
blog comments powered by Disqus