[Ns-developers] ns3: random numbers
Michele Weigle
mweigle at cs.odu.edu
Thu Mar 8 10:51:53 PST 2007
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
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
-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
(757) 683-6001 ext. 5050
More information about the Ns-developers
mailing list