Initializing random seeds

Corrado Santoro csanto@REDACTED
Wed Feb 8 09:45:16 CET 2006


I'm trying to use the functions of the random module to generate random 
numbers in different processes, but I have a problem with 
initialization. I know that the seed is stored in the process' 
properties so I'm initializing the seed in each process using the value 
returned by function now(). But I obtain the same random number sequence 
for each process. I've tried a simple code, attached to this email, and 
the output is:

30> rndtest:start().
Seed of <0.128.0> is {1139,388083,514683}
Seed of <0.129.0> is {1139,388083,514695}
Seed of <0.130.0> is {1139,388083,514701}
Seed of <0.131.0> is {1139,388083,514707}
<0.131.0>Number generated from proc <0.128.0> is 9
Number generated from proc <0.129.0> is 9
Number generated from proc <0.130.0> is 9
Number generated from proc <0.131.0> is 9


Do you have an hint to avoid this problem? Indeed I could solve the 
problem by using random number generator process and call it each time I 
need a new random number, but I would like to know if a different 
solution could be possible.


Regards,
--Corrado

-- 
======================================================
Eng. Corrado Santoro, Ph.D.

University of Catania - Engineering Faculty
Department of Computer Science and
Telecommunications Engineering
Viale A. Doria, 6 - 95125 CATANIA (ITALY)

Tel: +39 095 7382380
      +39 095 7387035
      +39 095 7382365
      +39 095 7382364

VoIP: sip:7035@REDACTED

Fax: +39 095 7382397

EMail: csanto@REDACTED
Personal Home Page:
             http://www.diit.unict.it/users/csanto

NUXI Home Page:
             http://nuxi.diit.unict.it
======================================================

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: rndtest.erl
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20060208/d50440cf/attachment.ksh>


More information about the erlang-questions mailing list