[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Global random generator usage (java/Linux)
From: |
Marcus G. Daniels |
Subject: |
Re: Global random generator usage (java/Linux) |
Date: |
07 Dec 2001 10:41:36 -0700 |
User-agent: |
Gnus/5.070084 (Pterodactyl Gnus v0.84) Emacs/20.7 |
>>>>> "BI" == Benjamin Inden <address@hidden> writes:
BI> I wonder how I can use the global random generator with a
BI> Bernoulli Distribution.
BI> I also wonder how I can explicitly set the global random
BI> generator's initial seed to a certain value. I want just one
BI> integer number to determine the whole run.
See below for an example. For the latter, you can use the -S option with a
positive integer.
import swarm.Globals;
import swarm.random.BernoulliDist;
import swarm.random.BernoulliDistImpl;
import swarm.defobj.Zone;
public class BernoulliTest {
public static void main (String args []) {
Globals.env.initSwarm ("BernoulliTest", "0.0", "address@hidden",
args);
Zone aZone = Globals.env.globalZone;
// force a seed, even if -s or -S is set
// Globals.env.randomGenerator.setStateFromSeed (2);
BernoulliDist bernoulliDist =
new BernoulliDistImpl (aZone, Globals.env.randomGenerator, .5);
System.out.println (bernoulliDist.getIntegerSample ());
}
}
==================================
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.