[Ns-developers] ns3: random numbers

Raj Bhattacharjea raj.b at gatech.edu
Fri Mar 9 08:53:57 PST 2007


In light of Michele's last e-mail and a quick conference call with her,
we've decided to take her suggestions as outlined below:

1) We will add a static function to the RandomVariable base class called
SetRunNumber,
which will have an integer argument, which will be saved in a static,
private global
variable called "RandomVariable::runNumber".

2) Each time a new random variable is initialized (seeded), we will call
ResetNextSubstream
runNumber times.

3) We will continue to, by default, set the global random stream with either
/dev/random
or the time of day, but will provide an API so the user can have access to
the
see that was used in the case of something interesting about that particular
seed.

4) We will suggest to users, via documentation, that the SetRunNumber static
member
be called whenever they are running multiple independent runs, for example
when
computing averages, confidence intervals, etc.  An obvious way to do this is
to suggest
command line argument such as "runNumber=2".  Further, in this case, we will
suggest
that they use the "global seed" method, rather than allow the random
seeding.

5) We will remove the ability to individually seed a specific random
variable.  We had originally
thought this might be useful, but Michelle convinced us otherwise.

Look for more on this early next week as these changes are implemented.
-- 
Raj Bhattacharjea
Georgia Institute of Technology
School of Electrical and Computer Engineering
Systems Analyst
404.894.2955
On 3/8/07, Michele Weigle < mweigle at cs.odu.edu> wrote:
>
> On Mar 5, 2007, at 4:26 PM, Raj Bhattacharjea wrote:
> > I've posted my propoosal for what random number generators should
> > look like
> > in NS-3.  It can be found at:
> > http://code.nsnam.org/raj/ns-3-rng
> > In the files src/core/rng-stream.{h,cc} and src/core/random-
> > variable.{h,cc}
> >
> > I'd like to ask for comments and suggestions on this.  The
> > underlying RNG
> > used is the same RngStream from NS-2, only the API is significanly
> > different.  I've made some very preliminary histogram plots in Octave
> > demonstrating that the distributions are in fact what we claim they
> > are.
> > http://www.prism.gatech.edu/~gtg037s/NS3_RNG_Tests/tests.html<http://www.prism.gatech.edu/%7Egtg037s/NS3_RNG_Tests/tests.html>
>    I like that each random variable has its own separate RNG stream.
> With this, you're assured that within a simulation run, values from
> your random variables will be independently drawn.
>
>    There does need to be access to ResetNextSubstream() because this
> allows the user to advance to the next substream in the case of
> running multiple independent replications.  Ideally, for the 2nd run
> of a simulation, you'd want to call ResetNextSubstream() once for all
> of the RandomVariables that you're using, and then on the 3rd run,
> you'd want to call it twice.  To make this easier, we probably should
> add a SetSubstream(int) function that will call ResetNextSubstream()
> the appropriate number of times to advance to the desired substream.
>
>    It'd be great if there was some way to have some meta-class that
> all of your RandomVariables belonged to.  Then, the user wouldn't
> have to remember to call SetSubstream() on all of the
> RandomVariables, just call it once and it gets called on all of them
> automatically.  Actually, having something like this might help with
> the seeding issue that I'll mention next.
>
>    It's fine to set the package seed (SetPackageSeed), but I don't
> think that we should use SetSeed(). (L'Ecuyer even mentions in the
> paper that's the source of this code that SetSeed() shouldn't really
> be used.)  We really only want to allow the user to set the package
> seed once for the entire simulation before any other RNGStreams are
> created.  The power of L'Ecuyer's implementation is that once you set
> the seed at the beginning, all newly created RNG streams are
> guaranteed to be independent, without having to set the seed
> manually.  So, maybe in this meta-class, there's a SetSeed()
> function, but it shouldn't be accessible for individual RNGStreams,
> and it should be usable only if there currently exists just a single
> RNGStream object.
>
>    I'm torn between having the default seed be picked by time of day
> or just using a constant seed.  I understand that the constant seed
> can be confusing if you're expecting a different result each time you
> run the simulation, but it's important that the user realize that the
> data from those runs (that use time of day as the seed) may not be
> independent.  The only way to guarantee independence between
> simulation runs is to use the substream mechanism.
>
>    BTW, if you don't have a copy of L'Ecuyer's paper, here it is:
> http://www.iro.umontreal.ca/~lecuyer/myftp/papers/streams00.pdf<http://www.iro.umontreal.ca/%7Elecuyer/myftp/papers/streams00.pdf>
>
> -Michele
>
> --
> Michele Weigle
> Assistant Professor
> Department of Computer Science
> Old Dominion University
> Norfolk, VA 23539
> mweigle at cs.odu.edu
> http://www.cs.odu.edu/~mweigle <http://www.cs.odu.edu/%7Emweigle>
> (757) 683-6001 ext. 5050
>
>
>
>


More information about the Ns-developers mailing list