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, const long sum)
 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,
const long  sum 
)

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.
sumThe sum of the counts seen up to value, used to show the CDF for value.

Definition at line 89 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 107 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 129 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 two-ray-to-three-gpp-ch-calibration::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 60 of file empirical-random-variable-example.cc.