A Discrete-Event Network Simulator
API
Core example: Empirical random variables use.

Example program illustrating use of ns3::EmpiricalRandomVariable. More...

Functions

void PrintStatsLine (const double value, const long count, const long n)
 Prints a stat line. More...
 
void PrintSummary (long sum, long n, double weighted, double expected)
 Prints the summary. More...
 
void RunBothModes (std::string mode, Ptr< EmpiricalRandomVariable > erv, long n)
 Sample the random variable. More...
 
void RunSingleSample (std::string mode, Ptr< EmpiricalRandomVariable > erv)
 Sample the random variable only once. More...
 

Detailed Description

Example program illustrating use of ns3::EmpiricalRandomVariable.

This example illustrates

Consult the ns-3 manual for more information about the use of the random number generator

Function Documentation

◆ PrintStatsLine()

void PrintStatsLine ( const double  value,
const long  count,
const long  n 
)

Prints a stat line.

Parameters
valueThe value to print.
countThe number of times that value has been sampled.
nThe total number of random values sampled.

Definition at line 90 of file empirical-random-variable-example.cc.

Referenced by RunBothModes().

+ Here is the caller graph for this function:

◆ PrintSummary()

void PrintSummary ( long  sum,
long  n,
double  weighted,
double  expected 
)

Prints the summary.

Parameters
sumThe number of sampled values.
nThe total number of random values to be drawn.
weightedThe average of the sample.
expectedThe expected average of the sample.

Definition at line 110 of file empirical-random-variable-example.cc.

Referenced by RunBothModes().

+ Here is the caller graph for this function:

◆ RunBothModes()

void RunBothModes ( std::string  mode,
Ptr< EmpiricalRandomVariable erv,
long  n 
)

Sample the random variable.

Parameters
modeRng mode (Normal or Antithetic).
ervThe empirical random variable.
nNumber of samples to draw.

Definition at line 139 of file empirical-random-variable-example.cc.

References ns3::Histogram::AddValue(), ns3::Histogram::GetBinCount(), ns3::Histogram::GetBinStart(), ns3::Histogram::GetBinWidth(), ns3::Histogram::GetNBins(), PrintStatsLine(), PrintSummary(), and visualizer.core::start().

+ Here is the call graph for this function:

◆ RunSingleSample()

void RunSingleSample ( std::string  mode,
Ptr< EmpiricalRandomVariable erv 
)

Sample the random variable only once.

Parameters
modeRng mode (Normal or Antithetic).
ervThe empirical random variable.

Definition at line 63 of file empirical-random-variable-example.cc.