[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Swarm-Support] Query regarding changing seed in a RNG
From: |
Paul Johnson |
Subject: |
Re: [Swarm-Support] Query regarding changing seed in a RNG |
Date: |
Fri, 14 Sep 2007 12:29:00 -0500 |
User-agent: |
Thunderbird 2.0.0.5 (X11/20070719) |
Kavita Gangal wrote:
Hello,
My problem is as follows:
I need to generate varying series of random integers between 1 and 60 using
swarm Random Number Generators.
Currently I am using the following syntax:
Globals.env.uniformIntRand.getIntegerWithMin$withMax (1,60);
But it turns out that, in this, the Initial seed can not vary. So each time
when the program is run, it generates the SAME series.
And,
Yes, the sequence is the same every time because we want to make sure
models are replicatable. If you want to change the seed, you can do so.
The command line option to set the seed for the default RNG is -S
and in your code you can set the seed easily. the setStateFromSeed
command tells a generator to do so:
[myGenerator setStateFromSeed: 46464];
Here's an obj-c example where I grab a random number integer from the
default randomGenerator and use that as a seed for a new MT19937 generator
long initseed = [randomGenerator getUnsignedSample];
aGenerator = [MT19937gen create: aZone
setStateFromSeed: initseed];
And then that generator is used to initialize a new uniform distribution
uniformDist1 = [UniformDoubleDist create: aZone setGenerator:
aGenerator setDoubleMin: 0.0 setMax: 1.0];
IN your case, I think you should follow this same logic. Either use the
builtin randomGenerator or create a new one, then create a distribution
object.
myDist = [UniformIntegerDist: aZone setGenerator: myGenerator
setIntegerMin: 1 setIntegerMax: 60];
Or, if you already have the distribution object in hand, you can just do
[myDist setIntegerMin: 1 setMax: 60];
--
Paul E. Johnson email: address@hidden
Dept. of Political Science http://pj.freefaculty.org
1541 Lilac Lane, Rm 504
University of Kansas Office: (785) 864-9086
Lawrence, Kansas 66044-3177 FAX: (785) 864-5700
- Re: [Swarm-Support] Query regarding changing seed in a RNG,
Paul Johnson <=