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...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

double uniform (double a, double b) – return a number sampled from a uniform distribution on [a, b]double exponential (void) – return a number sampled from an exponential distribution with mean 1.0double exponential (double k) – return a number sampled from an exponential distribution with mean kdouble normal (double avg, double std) – return a number sampled from a normal distribution with thegiven average <strong>and</strong> st<strong>and</strong>ard devi<strong>at</strong>iondouble lognormal (double avg, double std) – return a number sampled from a lognormal distribution withthe given average <strong>and</strong> st<strong>and</strong>ard devi<strong>at</strong>ionExample/* cre<strong>at</strong>e new RNGs */RNG arrival (23456);RNG size;/* set the RNGs to the appropri<strong>at</strong>e substream */for (int i = 1; i < 3; i++) {arrival.reset_next_substream();size.reset_next_substream();}/* print the first 5 arrival times <strong>and</strong> sizes */for (int j = 0; j < 5; j++) {printf ("%-8.3f %-4d\n", arrival.lognormal(5, 0.1),int(size.normal(500, 10)));}Output161.826 506160.591 503157.145 509137.715 507118.573 49625.2 R<strong>and</strong>om Variables<strong>The</strong> class R<strong>and</strong>omVariable provides a thin layer of functionality on top of the base r<strong>and</strong>om number gener<strong>at</strong>or <strong>and</strong> thedefault r<strong>and</strong>om number stream. It is defined in ~<strong>ns</strong>/ranvar.h:class R<strong>and</strong>omVariable : public TclObject {public:virtual double value() = 0;int comm<strong>and</strong>(int argc, co<strong>ns</strong>t char*co<strong>ns</strong>t* argv);R<strong>and</strong>omVariable();225

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

Saved successfully!

Ooh no, something went wrong!