A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
Core example: Empirical random variables use.
+ Collaboration diagram for Core example: Empirical random variables use.:

Files

file  empirical-random-variable-example.cc
 Example program illustrating use of ns3::EmpiricalRandomVariable.
 

Functions

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

Detailed Description

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 93 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 111 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 133 of file empirical-random-variable-example.cc.

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

+ 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 64 of file empirical-random-variable-example.cc.