Getting a *more* random value

Ulf Wiger (AL/EAB) <>
Wed Mar 29 10:04:33 CEST 2006


Random has a hard-coded default seed. That's 
why you get the same series for each run.

Calling e.g.

{I1,I2,I3} = erlang:now(),
random:seed(I1,I2,I3).

would give you a new series each time.

BR,
Ulf W 

> -----Original Message-----
> From:  
> [mailto:] On Behalf Of Pupeno
> Sent: den 29 mars 2006 01:41
> To: 
> Subject: Getting a *more* random value
> 
> Hello.
> I have an application where new processes are launched which 
> calculate one random number between 0 and 512 and then do 
> something with that number and terminate.
> I am currently using random:uniform(513) - 1 but that gives 
> me the same random value for all the processes for each run 
> of the application. I see that consecutive calls would get 
> other numbers but I only need one.
> How am I supposed to get a number that is not the same on 
> every process ?
> Thank you.
> --
> Pupeno <> (http://pupeno.com)
> 



More information about the erlang-questions mailing list