[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Q: confusion about random generators
From: |
Sven Thommesen |
Subject: |
Re: Q: confusion about random generators |
Date: |
Tue, 31 Jul 2001 09:43:43 -0500 |
At 03:42 PM 7/31/01 +0200, you wrote:
Hi there,
I have been checking the mailing list archive and found some mails about
seeds and random generation. I found one dated 1997 which about the
"danger" of using the UniformInteger and the other random number
distributions. Obviously I have done my program without this valuable
knowledge and now I'm panicking!! I'm working with the version 2.1.1 of
swarm and have now a big confusion about how to generate then random
numbers and about the problem of declaring many generators in an app.
I'm trying now to use the the java Random class, but as java doesn't
allow global variables I'm struggling to find out how to use the same
random generator in all my classes and give the seed as an argument at
running the program. So my questions are these two:
1. What is the right way of doing this?
2. how can I change my seed to run different simulations?
thanks a lot for any help,
Isis
Isis,
since you don't tell us which 1997 mail you are talking about, it is not
clear what "danger" you are talking about, or why you should be panicking.
There is at the moment no reason why you should not use the built-in
default generator in Swarm; it is high quality and reasonably fast. (Paul
Johnson even went through and speeded things up recently.) The default
generator is globally accessible from within your program as
'Globals.env.randomGenerator'.
It seems from your post that you have not read the documentation, and that
is always a good place to start. The Swarm User Guide and its appendices
has an extensive discussion on how to use the random generators and the
distribution objects. (I'd give you a url, but it seems the swarm.org
server is down at the moment.) You can choose to use the default generator
for all your random numbers (it has a long enough period for that), or you
may create several different generators; there are many to choose from. The
documentation describes the factors to consider when you make your choice.
Note that after the documentation was written, Marcus has added the command
line switch "-S=seedvalue" to allow you to set the seed for the default
random generator when your simulation starts up.
If after reading the docs you have more specific questions, I'll be happy
to help.
Cheers,
Sven Thommesen
==================================
Swarm-Support is for discussion of the technical details of the day
to day usage of Swarm. For list administration needs (esp.
[un]subscribing), please send a message to <address@hidden>
with "help" in the body of the message.