[Ns-developers] ns3: random numbers
Michele Weigle
mweigle at cs.odu.edu
Mon Mar 12 09:30:34 PDT 2007
On Mar 12, 2007, at 11:40 AM, mathieu lacage wrote:
> On Fri, 2007-03-09 at 11:53 -0500, Raj Bhattacharjea wrote:
>> 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.
>
> I am sorry but I don't know enough about the lecuyer code to
> understand
> what this means.
>
> Would you care to describe what you are trying to achieve with this
> change from an end-user point of view in end-user-understandable terms
> (I am really one of these). i.e., when I create a RandomVariable,
> how is
> it seeded ? What methods change the way it is seeded ? What is their
> impact on the seeding policy ? What is the default seeding policy ?
I'll try. =)
There's a global seed that's either set by default or set by the user
at the beginning of their simulation script/code. This seed is used
to generate all other seeds used by all other RandomVariables. Each
seed is guaranteed to generate a stream of random numbers that is
independent from all of the other streams of random numbers.
The only way to change the way that RandomVariables are seeded is to
change the global seed at the beginning of the simulation. This just
changes the starting seed. There is no way (and should be no reason)
to change the way that the seeding is actually performed.
To generate multiple independent replications of a simulation (for
example, for computing the mean and confidence interval of some
metric), you should set the runNumber global variable along with the
global seed. The global seed should be the same for all runs of the
simulation, and runNumber should be incremented for each run of the
simulation. Behind the scenes, the RNG will seed the RandomVariables
such that not only are all RandomVariables within a simulation run
independent, but that all RandomVariables over all simulation runs
are independent.
Hope this helps.
-Michele
More information about the Ns-developers
mailing list