swarm-support
[Top][All Lists]
Advanced

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

Re: random number seed


From: Marcus G. Daniels
Subject: Re: random number seed
Date: 04 Apr 2001 21:48:56 -0700
User-agent: Gnus/5.070084 (Pterodactyl Gnus v0.84) Emacs/20.4

>>>>> "AC" == Andre Costa <address@hidden> writes:

AC> is there a simple way to change the random number seed used when

AC>     Globals.env.uniformDblRand.getDoubleWithMin$withMax(a, b);

AC> is called ? 

Sure, see below.

AC> I have tried a few things with no success, but it
AC> seems that it may be easier to just create an instance of
        
AC>     UniformDoubleDistImpl

AC> with a generator of choice, and whose seed I set myself.

AC> Is this infact the easiest way to go, or can I change somehing in
AC> Globals instead ?

That's not a bad approach, since it gives you complete control if you
have several random steams you want to control for debugging purposes.

import swarm.Globals;

public class TestSetSeed {
    static void main (String args[]) {
        Globals.env.initSwarm ("TestSetSeed", "0.0", "address@hidden",
                               args);

        Globals.env.randomGenerator.setStateFromSeed (1);

        double val =
            Globals.env.uniformDblRand.getDoubleWithMin$withMax (0.0, 1.0);

        System.out.println (val);
    }
}

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