swarm-support
[Top][All Lists]
Advanced

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

Re: built in rv objects


From: Benedikt Stefansson
Subject: Re: built in rv objects
Date: Tue, 26 Jan 1999 17:54:39 -0800

Rick,

In addition to what Van Dung wrote; the following objects are "global"
variables once initSwarm() has been called in main.m (see /random/random.m:)

id <MT19937gen>          randomGenerator;

id <UniformIntegerDist>   uniformIntRand;
id <UniformUnsignedDist>  uniformUnsRand;
id <UniformDoubleDist>    uniformDblRand;

 If one only needs uniform distributions,  one can simply seed the generator
instance (randomGenerator) and then get down to business. Since the MT19937
generator is good enough for most purposes (see Matsumoto, M. and Kurita, Y.
(1998) "Mersenne twister a 623-dimensionally equidistributed uniform
pseudo-random number generator", ACM Transactions on Modeling and Computer
Simulations, 8 (1), pages 3-30), there is little reason to use any of the other
generators provideed (Sven once published some statistics on speed, which might
be a consideration in some cases). The three distributions are already global
and ready to rumble. I.e. the following code is actually superfluous:

Van Dung Ly wrote:

> - buildObjects
> {
> // snip
>
>   id <UniformDoubleDist> udd;
>
>   udd = [ UniformDoubleDist
>           create: [self getZone]
>           setGenerator: [MT19937gen create: [self getZone]
>                                     setStateFromSeed: SLEEPYSEED] ];
> //snip

To do the same thing you only need the following line:

[randomGenerator setSeed: SLEEPYSEED];

and then one can call the instance -uniformDoubleRand which is already
provided.

Regards,
-Benedikt

PS. Note that the different generators are amply documented, the only problem
is maybe that the random libary is huge and there is in effect to much
information:
http://www.santafe.edu/projects/swarm/swarmdocs/set/swarm.random.sgml.reference.html

--
----------------
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.



reply via email to

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