OMNeT++ Simulation Library  5.6.1
Discrete Distributions

Description

Random variate generators for discrete distributions.

Classes

class  cIntUniform
 Generates random numbers from the discrete uniform distribution. More...
 
class  cIntUniformExcl
 Generates random numbers from the discrete uniform distribution. More...
 
class  cBernoulli
 Generates random numbers that are the results of Bernoulli trials. More...
 
class  cBinomial
 Generates random numbers from the binomial distribution. More...
 
class  cGeometric
 Generates random numbers from the geometric distribution. More...
 
class  cNegBinomial
 Generates random numbers from the negative binomial distribution. More...
 
class  cPoisson
 Generates random numbers from the Poisson distribution. More...
 

Functions

SIM_API int intuniform (cRNG *rng, int a, int b)
 Returns a random integer with uniform distribution in the range [a,b], inclusive. (Note that the function can also return b.) More...
 
SIM_API int intuniformexcl (cRNG *rng, int a, int b)
 Returns a random integer with uniform distribution over [a,b), that is, from [a,b-1]. More...
 
int bernoulli (cRNG *rng, double p)
 Returns the result of a Bernoulli trial with probability p, that is, 1 with probability p and 0 with probability (1-p). More...
 
SIM_API int binomial (cRNG *rng, int n, double p)
 Returns a random integer from the binomial distribution with parameters n and p, that is, the number of successes in n independent trials with probability p. More...
 
SIM_API int geometric (cRNG *rng, double p)
 Returns a random integer from the geometric distribution with parameter p, that is, the number of independent trials with probability p until the first success. More...
 
SIM_API int negbinomial (cRNG *rng, int n, double p)
 Returns a random integer from the negative binomial distribution with parameters n and p, that is, the number of failures occurring before n successes in independent trials with probability p of success. More...
 
SIM_API int poisson (cRNG *rng, double lambda)
 Returns a random integer from the Poisson distribution with parameter lambda, that is, the number of arrivals over unit time where the time between successive arrivals follow exponential distribution with parameter lambda. More...
 

Function Documentation

◆ intuniform()

SIM_API int omnetpp::intuniform ( cRNG rng,
int  a,
int  b 
)

Returns a random integer with uniform distribution in the range [a,b], inclusive. (Note that the function can also return b.)

Parameters
a,bthe interval, a<b
rngthe underlying random number generator

Referenced by cComponent::intuniform(), and omnetpp::lognormal().

◆ intuniformexcl()

SIM_API int omnetpp::intuniformexcl ( cRNG rng,
int  a,
int  b 
)

Returns a random integer with uniform distribution over [a,b), that is, from [a,b-1].

Parameters
a,bthe interval, a<b
rngthe underlying random number generator

Referenced by cComponent::intuniformexcl(), and omnetpp::lognormal().

◆ bernoulli()

int omnetpp::bernoulli ( cRNG rng,
double  p 
)
inline

Returns the result of a Bernoulli trial with probability p, that is, 1 with probability p and 0 with probability (1-p).

Generation is using elementary look-up.

Parameters
p0=<p<=1
rngthe underlying random number generator

References omnetpp::binomial(), cRNG::doubleRand(), omnetpp::geometric(), omnetpp::negbinomial(), and omnetpp::poisson().

Referenced by cComponent::bernoulli().

◆ binomial()

SIM_API int omnetpp::binomial ( cRNG rng,
int  n,
double  p 
)

Returns a random integer from the binomial distribution with parameters n and p, that is, the number of successes in n independent trials with probability p.

Generation is using the relationship to Bernoulli distribution (runtime is proportional to n).

Parameters
nn>=0
p0<=p<=1
rngthe underlying random number generator

Referenced by omnetpp::bernoulli(), and cComponent::binomial().

◆ geometric()

SIM_API int omnetpp::geometric ( cRNG rng,
double  p 
)

Returns a random integer from the geometric distribution with parameter p, that is, the number of independent trials with probability p until the first success.

This is the n=1 special case of the negative binomial distribution.

Generation uses inverse transform.

Parameters
p0<p<=1
rngthe underlying random number generator

Referenced by omnetpp::bernoulli(), and cComponent::geometric().

◆ negbinomial()

SIM_API int omnetpp::negbinomial ( cRNG rng,
int  n,
double  p 
)

Returns a random integer from the negative binomial distribution with parameters n and p, that is, the number of failures occurring before n successes in independent trials with probability p of success.

Generation is using the relationship to geometric distribution (runtime is proportional to n).

Parameters
nn>=0
p0<p<1
rngthe underlying random number generator

Referenced by omnetpp::bernoulli(), and cComponent::negbinomial().

◆ poisson()

SIM_API int omnetpp::poisson ( cRNG rng,
double  lambda 
)

Returns a random integer from the Poisson distribution with parameter lambda, that is, the number of arrivals over unit time where the time between successive arrivals follow exponential distribution with parameter lambda.

Lambda is also the mean (and variance) of the distribution.

Generation method depends on value of lambda:

  • 0<lambda<=30: count number of events
  • lambda>30: Acceptance-Rejection due to Atkinson (see Banks, page 166)
Parameters
lambda> 0
rngthe underlying random number generator

Referenced by omnetpp::bernoulli(), and cComponent::poisson().