12.07.2015 Views

The ns Manual (formerly ns Notes and Documentation)1 - NM Lab at ...

The ns Manual (formerly ns Notes and Documentation)1 - NM Lab at ...

The ns Manual (formerly ns Notes and Documentation)1 - NM Lab at ...

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 25M<strong>at</strong>hem<strong>at</strong>ical Support<strong>The</strong> simul<strong>at</strong>or includes a small collection of m<strong>at</strong>hem<strong>at</strong>ical functio<strong>ns</strong> used to implement r<strong>and</strong>om vari<strong>at</strong>e gener<strong>at</strong>ion <strong>and</strong> integr<strong>at</strong>ion.This area of the simul<strong>at</strong>or is currently undergoing some changes.<strong>The</strong> procedures <strong>and</strong> functio<strong>ns</strong> described in this chapter can be found in ~<strong>ns</strong>/tools/rng.{cc, h}, ~<strong>ns</strong>/tools/r<strong>and</strong>om.{cc, h},~<strong>ns</strong>/tools/ranvar.{cc, h}, ~<strong>ns</strong>/tools/pareto.{cc, h}, ~<strong>ns</strong>/tools/expoo.{cc, h}, ~<strong>ns</strong>/tools/integr<strong>at</strong>or.{cc, h}, <strong>and</strong> ~<strong>ns</strong>/tcl/lib/<strong>ns</strong>r<strong>and</strong>om.tcl.25.1 R<strong>and</strong>om Number Gener<strong>at</strong>ion<strong>The</strong> RNG class contai<strong>ns</strong> an implement<strong>at</strong>ion of the combined multiple recursive gener<strong>at</strong>or MRG32k3a proposed by L’Ecuyer[16]. <strong>The</strong> C++ code was adapted from [18]. This replaces the previous implement<strong>at</strong>ion of RNG, which used the minimalst<strong>and</strong>ard multiplic<strong>at</strong>ive linear congruential gener<strong>at</strong>or of Park <strong>and</strong> Miller [27]. <strong>The</strong> newer (MRG32k3a) RNG is used in <strong>ns</strong>versio<strong>ns</strong> 2.1b9 <strong>and</strong> l<strong>at</strong>er.<strong>The</strong> MRG32k3a gener<strong>at</strong>or provides 1.8x10 19 independent streams of r<strong>and</strong>om numbers, each of which co<strong>ns</strong>ists of 2.3x10 15substreams. Each substream has a period (i.e., the number of r<strong>and</strong>om numbers before overlap) of 7.6x10 22 . <strong>The</strong> period of theentire gener<strong>at</strong>or is 3.1x10 57 . Figure 25.1 provides a graphical idea of how the streams <strong>and</strong> substreams fit together.A default RNG (defaultRNG), cre<strong>at</strong>ed <strong>at</strong> simul<strong>at</strong>or initializ<strong>at</strong>ion time, is provided. If multiple r<strong>and</strong>om variables are used ina simul<strong>at</strong>ion, each r<strong>and</strong>om variable should use a separ<strong>at</strong>e RNG object. When a new RNG object is cre<strong>at</strong>ed, it is autom<strong>at</strong>icallyseeded to the beginning of the next independent stream of r<strong>and</strong>om numbers. Used in this manner, the implement<strong>at</strong>ion allowsfor a maximum of 1.8x10 19 r<strong>and</strong>om variables.Often, multiple independent replic<strong>at</strong>io<strong>ns</strong> of a simul<strong>at</strong>ion are needed (i.e., to perform st<strong>at</strong>istical analysis given multiple ru<strong>ns</strong>with fixed parameters). For each replic<strong>at</strong>ion, a different substream should be used to e<strong>ns</strong>ure th<strong>at</strong> the r<strong>and</strong>om number streamsare independent. (This process is given as an OTcl example l<strong>at</strong>er.) This implement<strong>at</strong>ion allows for a maximum of 2.3x10 15independent replic<strong>at</strong>io<strong>ns</strong>. Each r<strong>and</strong>om variable in a single replic<strong>at</strong>ion can produce up to 7.6x10 22 r<strong>and</strong>om numbers beforeoverlapping.Note: Only the most common functio<strong>ns</strong> are described here. For more inform<strong>at</strong>ion, see [18] <strong>and</strong> the source code found intools/rng.h <strong>and</strong> tools/rng.cc. For a comparison of this RNG to the more common LCG16807 RNG (<strong>and</strong> whyLCG16807 is not a good RNG), see [17].220

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!