Discrete distributions
[Random number generation]

Functions

SIM_API int intuniform (int a, int b, int rng=0)
int bernoulli (double p, int rng=0)
SIM_API int binomial (int n, double p, int rng=0)
SIM_API int geometric (double p, int rng=0)
SIM_API int negbinomial (int n, double p, int rng=0)
SIM_API int poisson (double lambda, int rng=0)

Function Documentation

int bernoulli ( double  p,
int  rng = 0 
) [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:
p 0=<p<=1
rng the underlying random number generator

References genk_dblrand().

SIM_API int binomial ( int  n,
double  p,
int  rng = 0 
)

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:
n n>=0
p 0<=p<=1
rng the underlying random number generator
SIM_API int geometric ( double  p,
int  rng = 0 
)

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:
p 0<p<=1
rng the underlying random number generator
SIM_API int intuniform ( int  a,
int  b,
int  rng = 0 
)

Returns a random integer with uniform distribution in the range [a,b], inclusive.

(Note that the function can also return b.)

Parameters:
a,b the interval, a<b
rng the underlying random number generator
SIM_API int negbinomial ( int  n,
double  p,
int  rng = 0 
)

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:
n n>=0
p 0<p<1
rng the underlying random number generator
SIM_API int poisson ( double  lambda,
int  rng = 0 
)

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
rng the underlying random number generator
Generated on Mon Jul 14 12:57:23 2014 for OMNeT++ Simulation Library by  doxygen 1.6.3