swarm-support
[Top][All Lists]
Advanced

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

Re: Random number generators. advice?


From: Joshua Madden
Subject: Re: Random number generators. advice?
Date: Wed, 21 Feb 2001 10:32:22 -0800 (Pacific Standard Time)

On Wed, 21 Feb 2001, Paul E Johnson wrote:

> I'm trying to make two "similar" models, one in obj-c and one in java,
> generate the exact same results.  In order to do that, I need the exact
> same random numbers at the start, and I'm having trouble because one
> program makes draws on the random generator more than the other, so the
> numbers for some variables don't match up. 
> 
> As a result, I need to create three or four different generator objects
> which can be called at just the right time so that the numbers will be
> identical in the two simulations.  At random, I chose to add the
> generator C3MWCgen and a couple others.  On the objc side that's OK, but
> there is no Java Swarm interface for that one.
> 
> So then I thought I might as well just ask the experts which generators
> to use, if one needs separate generators to keep random numbers matched
> up.

There are two things that make two RNGs give you the same sequence of
values: 
(1) They must be using the same generating function; and
(2) They must be given the same seed (initial value).

It sounds as though your problem is that one model needs more "random"
numbers than the other.  In that case, if you know exactly how many random
numbers will be used by model 1 and not model 2, then you can just ask for
"dummy" values in model 2 between the real ones.

E.g.: model 1 needs 5 random numbers, model 2 needs 3, which must match up
with model 1's numbers 1, 2, and 5:

[model 2 code]
rand1 = rand.getInt();
...
rand2 = rand.getInt();
rand.getInt();
rand.getInt();
...
rand3 = rand.getInt();

Is that what you're looking for?

Joshua

address@hidden Per Obscurius...cs.uoregon.edu/~jmadden
    Joshua Madden: Information Scientist, Musician, Philosopher-At-Tall
It's that moment of dawning comprehension that I live for--Bill Watterson
My opinions are too rational and insightful to be those of any organization.


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