[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: random
From: |
Benedikt Stefansson |
Subject: |
Re: random |
Date: |
Tue, 14 Jul 1998 13:00:43 -0700 |
Amber L. Hinkle wrote:
> I am trying to generate random numbers with an exponential distribution.
> First, I don't know what generator to use. I also can't seem to be able
> to use command line parameters with the Cygnus Cygwin32 bash shell. I
> think using the command -varySeed would help but I can't get it to work.
Hi,
When you execute the function swarmInit() the Swarm kernel sets up a default
random number generator. This is, according to Sven's documentation, a
Mersenne Twister type generator with a single cycle of length 2^19937-1
which I think is the longest reported in the literature, in other words
pretty darn good. If you buy that, and since the pointer to the default
random number generator, "randomGenerator" is a global variable, you can
simply create and initialize your exponential distribution object thusly:
exponentialDistribution=[ExponentialDist create: [self getZone]
setGenerator: randomGenerator setMean: mean];
Where mean is a parameter which you choose. Since you are most probably
creating the generator in a Swarm, you can also substitute "self" for "[self
getZone]".
If you want to control the random number seed, insert this line before you
call the exponential distribution for the first time:
[randomGenerator setStateFromSeed: randomSeed];
where randomSeed is a parameter which you choose. This primes the generator,
and since you can control the parameter it's much better than using
--varySeed.
For more info refer to:
http://www.santafe.edu/projects/swarm/swarmdocs/html/set/swarm.random.sgml.reference.html
Regards,
-Benedikt
----------------
Benedikt Stefansson address@hidden
Department of Economics, UCLA Fax. (310) 825-9528
Los Angeles, CA 90095-1477 Tel. (310) 825-1777
==================================
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.
==================================
- random, Amber L. Hinkle, 1998/07/14
- Re: random,
Benedikt Stefansson <=