swarm-support
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Swarm-Support] Random Number Generator andDistributions(continuing)


From: Paul Johnson
Subject: Re: [Swarm-Support] Random Number Generator andDistributions(continuing)
Date: Fri, 30 Jan 2009 11:13:42 -0600
User-agent: Thunderbird 2.0.0.19 (X11/20090105)

Emerson Aguiar Noronha wrote:
Hello all,

Continuing with that email about RNG and distributions in swarm.

Ive made a change in the code and now its seems to be working according
with the distributions. But i´d like informations of why that behavior
could happen.

Now i creating setting a new instance of the rng s object instead of using
the swarm´s standard global rng object. Id like to know:

a. in code line(3..4): is that the better way of obtaing and setting a seed?

b. according wich ive read, its not necessary to create and set
programaticaly(line 2 .. 4) the rng object and is seed for the
distribution.

c. the same occurs using the uniform unsigned
implementation(UniformUnsignedDistImpl)

Follow the CODE:


 //Bernoulli
(1)MT19937genImpl    rng  = new MT19937genImpl(Globals.env.globalZone);

(2)BernoulliDistImpl dist = new BernoulliDistImpl(Globals.env.globalZone,
rng);

(3)int seed = Globals.env.randomGenerator.getUnsignedSample();

(4)rng.setStateFromSeed(seed);

(5)dist.setProbability(0.5);
//V.A
this.myinitialstate = dist.getIntegerSample();


thanks all of you,


I don't know anything what be wrong with this approach. I am pretty sure I've done it when I needed a discrete random number series for one object, as your "rng" thing provides.

I have asked about this topic a few times--how best to create, say, a lot of generators for different objects so that their random number streams would not be affected when other agents draw numbers. This may be important if you are comparing one simulation with 10 agents against a simulation with 20 agents. You'd like the "original 10" to keep acting the same way, and that means using the exact same random numbers. When you add 10 new, you don't want their draws to change the numbers for the others. From what I understand about MT19937, it should be feasible to create several separate generator objects and seed them randomly, and the numbers they give out should not be correlated. That's theory, though.

Glen Ropella was explaining that creating a lot of rng objects in that way was dubious, or possibly that it was just too slow. I'm scanning my email to find the explanation, but can't turn it up. Maybe he is reading now and he can remember the argument. He had an alternative generator approach in mind for a case like that, I think it was 'lookup table' or something similar to that. But, he was a math major, and I was not, and, like a goldfish following a shiny object, I lost determination on the problem and moved on to something else to get wrong :)

pj

--
Paul E. Johnson                       email: address@hidden
Professor, 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]