swarm-support
[Top][All Lists]
Advanced

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

Re: Double checking my understanding of Random Generator Docs


From: Sven N. Thommesen
Subject: Re: Double checking my understanding of Random Generator Docs
Date: Thu, 02 Jul 1998 17:39:07 -0500

Paul,

as far as I can tell what you've written below is quite correct. 

--Sven


At 03:45 PM 6/29/1998 -0500, Paul E. Johnson wrote:
>
>Dear Sven:
>I'm copying this to the list, since some other people might want
>to correct me.
>
>I want to be sure I don't make a mistake when I put this in the FAQ.
>There are so many options in random number generating it is hard 
>to give a simple answer.
>
>Question: How do I get random numbers from a particular distribution?
>
>Answer:  You create an object, say "aNormalDist." Then, when
>you need a random number, you get it by telling aNormalDist that you want
>one with "[aNormalDist getDoubleSample]". 
>
>       Pick the distribution you want (there are many, like "Normal,"
>"Uniform" etc listed in docs).  Suppose I want Normal random numbers
>with mean 0 and variance 1.  (Note you need to include random.h in your
>file to make this work).
>
>        There are many possible random number generators, that's where
>all the confusing stuff kicks in.  If you don't want to be an expert,
>use one of these two approaches.
>
>
>      1. Let Swarm do the work for you!
>
> Create the distribution object with this code:
>
>aNormalDist = [NormalDist createWithDefaults: [self getZone] setMean: 0
>           setVariance: 1] ;
>
>The "createWithDefaults" method creates aNormalDist and it also creates
>a generator from which that distribution object can get random numbers.
>You never specify which random generator and you don't need to!
>Which random generator is chosen is determined inside the Swarm libraries.
>Each distribution you create causes the creation of a new random number
>generator.
>
>     2. Force the usage of the default generator, MT19937.
>This random number generator is, practically speaking, an optimum mix of
>randomness and computer speed.  A generator called "randomGenerator" is
>created when you use the Swarm random library, and you are free to create
>distributions that use it as the supplier of random numbers. This is
>available globally, in any file where you want to create a
>distribution.  This creates the normal distribution object:
>  aNormalDist = [NormalDist create: [self getZone] 
>            setGenerator: randomGenerator  setMean: 0
>           setVariance: 1] ;
>If you create many distribution objects in many files, then they will all
>be drawing random numbers from the default "randomGenerator."  Some people
>in the mailing list think (emphatically) that is the best way to go.
>
>     Every time you run your program, the random number generators
>will start at the same "seed" and you will get the same results.  If
>you want to have the starting points chosen at random, do it by
>adding --varyseed on the command line when you type in the name of
>your program (i.e., ./heatbugs --varyseed).
>
>     If you need more control, you can get it. Choose a random number
>generator from Sven's incredible list and initialize it yourself and
>access it instead of "randomGenerator".  You can control the random number
>seed explicitly if you want. You can also make the generators give back
>information about themselves.  Check the docs
>
>
>Paul E. Johnson                       email: address@hidden
>Dept. of Political Science            http://lark.cc.ukans.edu/~pauljohn
>University of Kansas                  Office: (913) 864-9086
>Lawrence, Kansas 66045                FAX: (913) 864-5700
>
>
>                  ==================================
>   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.
>                  ==================================
>

                  ==================================
   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]