OMNeT++ Simulation Library  6.0.3
Continuous Distributions

Description

Random variate generators for continuous distributions.

Classes

class  cExponential
 Generates random numbers from the exponential distribution. More...
 
class  cNormal
 Generates random numbers from the normal distribution. More...
 
class  cTruncNormal
 Generates random numbers from the truncated normal distribution. More...
 
class  cGamma
 Generates random numbers from the gamma distribution. More...
 
class  cBeta
 Generates random numbers from the beta distribution. More...
 
class  cErlang
 Generates random numbers from the Erlang distribution. More...
 
class  cChiSquare
 Generates random numbers from the chi-square distribution. More...
 
class  cStudentT
 Generates random numbers from Student's T distribution. More...
 
class  cCauchy
 Generates random numbers from the Cauchy distribution. More...
 
class  cTriang
 Generates random numbers from the triangular distribution. More...
 
class  cWeibull
 Generates random numbers from the Weibull distribution. More...
 
class  cParetoShifted
 Generates random numbers from the shifted Pareto distribution. More...
 

Functions

SIM_API double uniform (cRNG *rng, double a, double b)
 Returns a random variate with uniform distribution in the range [a,b). More...
 
SimTime uniform (cRNG *rng, SimTime a, SimTime b)
 SimTime version of uniform(cRNG*,double,double), for convenience. More...
 
SIM_API double exponential (cRNG *rng, double mean)
 Returns a random variate from the exponential distribution with the given mean (that is, with parameter lambda=1/mean). More...
 
SimTime exponential (cRNG *rng, SimTime mean)
 SimTime version of exponential(cRNG*,double), for convenience. More...
 
SIM_API double normal (cRNG *rng, double mean, double stddev)
 Returns a random variate from the normal distribution with the given mean and standard deviation. More...
 
SimTime normal (cRNG *rng, SimTime mean, SimTime stddev)
 SimTime version of normal(cRNG*,double,double), for convenience. More...
 
SIM_API double truncnormal (cRNG *rng, double mean, double stddev)
 Normal distribution truncated to nonnegative values. More...
 
SimTime truncnormal (cRNG *rng, SimTime mean, SimTime stddev)
 SimTime version of truncnormal(cRNG*,double,double), for convenience. More...
 
SIM_API double gamma_d (cRNG *rng, double alpha, double theta)
 Returns a random variate from the gamma distribution with parameters alpha>0, theta>0. Alpha is known as the "shape" parameter, and theta as the "scale" parameter. More...
 
SIM_API double beta (cRNG *rng, double alpha1, double alpha2)
 Returns a random variate from the beta distribution with parameters alpha1, alpha2. More...
 
SIM_API double erlang_k (cRNG *rng, unsigned int k, double mean)
 Returns a random variate from the Erlang distribution with k phases and mean mean. More...
 
SIM_API double chi_square (cRNG *rng, unsigned int k)
 Returns a random variate from the chi-square distribution with k degrees of freedom. More...
 
SIM_API double student_t (cRNG *rng, unsigned int i)
 Returns a random variate from the student-t distribution with i degrees of freedom. If Y1 has a normal distribution and Y2 has a chi-square distribution with k degrees of freedom then X = Y1 / sqrt(Y2/k) has a student-t distribution with k degrees of freedom. More...
 
SIM_API double cauchy (cRNG *rng, double a, double b)
 Returns a random variate from the Cauchy distribution (also called Lorentzian distribution) with parameters a,b where b>0. More...
 
SIM_API double triang (cRNG *rng, double a, double b, double c)
 Returns a random variate from the triangular distribution with parameters a <= b <= c. More...
 
double lognormal (cRNG *rng, double m, double w)
 Returns a random variate from the lognormal distribution with "scale" parameter m and "shape" parameter w. m and w correspond to the parameters of the underlying normal distribution (m: mean, w: standard deviation.) More...
 
SIM_API double weibull (cRNG *rng, double a, double b)
 Returns a random variate from the Weibull distribution with parameters a, b > 0, where a is the "scale" parameter and b is the "shape" parameter. Sometimes Weibull is given with alpha and beta parameters, then alpha=b and beta=a. More...
 
SIM_API double pareto_shifted (cRNG *rng, double a, double b, double c)
 Returns a random variate from the shifted generalized Pareto distribution. More...
 

Function Documentation

◆ uniform() [1/2]

SIM_API double omnetpp::uniform ( cRNG rng,
double  a,
double  b 
)

Returns a random variate with uniform distribution in the range [a,b).

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

Referenced by cComponent::uniform().

◆ uniform() [2/2]

SimTime omnetpp::uniform ( cRNG rng,
SimTime  a,
SimTime  b 
)
inline

SimTime version of uniform(cRNG*,double,double), for convenience.

References SimTime::dbl().

◆ exponential() [1/2]

SIM_API double omnetpp::exponential ( cRNG rng,
double  mean 
)

Returns a random variate from the exponential distribution with the given mean (that is, with parameter lambda=1/mean).

Parameters
meanmean value
rngthe underlying random number generator

Referenced by cComponent::exponential().

◆ exponential() [2/2]

SimTime omnetpp::exponential ( cRNG rng,
SimTime  mean 
)
inline

SimTime version of exponential(cRNG*,double), for convenience.

References SimTime::dbl().

◆ normal() [1/2]

SIM_API double omnetpp::normal ( cRNG rng,
double  mean,
double  stddev 
)

Returns a random variate from the normal distribution with the given mean and standard deviation.

Parameters
meanmean of the normal distribution
stddevstandard deviation of the normal distribution
rngthe underlying random number generator

Referenced by cComponent::normal().

◆ normal() [2/2]

SimTime omnetpp::normal ( cRNG rng,
SimTime  mean,
SimTime  stddev 
)
inline

SimTime version of normal(cRNG*,double,double), for convenience.

References SimTime::dbl().

Referenced by omnetpp::lognormal().

◆ truncnormal() [1/2]

SIM_API double omnetpp::truncnormal ( cRNG rng,
double  mean,
double  stddev 
)

Normal distribution truncated to nonnegative values.

It is implemented with a loop that discards negative values until a nonnegative one comes. This means that the execution time is not bounded: a large negative mean with much smaller stddev is likely to result in a large number of iterations.

The mean and stddev parameters serve as parameters to the normal distribution before truncation. The actual random variate returned will have a different mean and standard deviation.

Parameters
meanmean of the normal distribution
stddevstandard deviation of the normal distribution
rngthe underlying random number generator

Referenced by cComponent::truncnormal().

◆ truncnormal() [2/2]

SimTime omnetpp::truncnormal ( cRNG rng,
SimTime  mean,
SimTime  stddev 
)
inline

SimTime version of truncnormal(cRNG*,double,double), for convenience.

References SimTime::dbl().

◆ gamma_d()

SIM_API double omnetpp::gamma_d ( cRNG rng,
double  alpha,
double  theta 
)

Returns a random variate from the gamma distribution with parameters alpha>0, theta>0. Alpha is known as the "shape" parameter, and theta as the "scale" parameter.

Some sources in the literature use the inverse scale parameter beta = 1 / theta, called the "rate" parameter. Various other notations can be found in the literature; our usage of (alpha,theta) is consistent with Wikipedia and Mathematica (Wolfram Research).

Gamma is the generalization of the Erlang distribution for non-integer k values, which becomes the alpha parameter. The chi-square distribution is a special case of the gamma distribution.

For alpha=1, Gamma becomes the exponential distribution with mean=theta.

The mean of this distribution is alpha*theta, and variance is alpha*theta2.

Generation: if alpha=1, it is generated as exponential(theta).

For alpha>1, we make use of the acceptance-rejection method in "A Simple Method for Generating Gamma Variables", George Marsaglia and Wai Wan Tsang, ACM Transactions on Mathematical Software, Vol. 26, No. 3, September 2000.

The alpha<1 case makes use of the alpha>1 algorithm, as suggested by the above paper.

Remarks
the name gamma_d is chosen to avoid ambiguity with a function of the same name
Parameters
alpha>0 the "shape" parameter
theta>0 the "scale" parameter
rngthe underlying random number generator

Referenced by cComponent::gamma_d().

◆ beta()

SIM_API double omnetpp::beta ( cRNG rng,
double  alpha1,
double  alpha2 
)

Returns a random variate from the beta distribution with parameters alpha1, alpha2.

Generation is using relationship to Gamma distribution: if Y1 has gamma distribution with alpha=alpha1 and beta=1 and Y2 has gamma distribution with alpha=alpha2 and beta=2, then Y = Y1/(Y1+Y2) has beta distribution with parameters alpha1 and alpha2.

Parameters
alpha1,alpha2>0
rngthe underlying random number generator

Referenced by cComponent::beta().

◆ erlang_k()

SIM_API double omnetpp::erlang_k ( cRNG rng,
unsigned int  k,
double  mean 
)

Returns a random variate from the Erlang distribution with k phases and mean mean.

This is the sum of k mutually independent random variables, each with exponential distribution. Thus, the kth arrival time in the Poisson process follows the Erlang distribution.

Erlang with parameters m and k is gamma-distributed with alpha=k and beta=m/k.

Generation makes use of the fact that exponential distributions sum up to Erlang.

Parameters
knumber of phases, k>0
mean>0
rngthe underlying random number generator

Referenced by cComponent::erlang_k().

◆ chi_square()

SIM_API double omnetpp::chi_square ( cRNG rng,
unsigned int  k 
)

Returns a random variate from the chi-square distribution with k degrees of freedom.

The chi-square distribution arises in statistics. If Yi are k independent random variates from the normal distribution with unit variance, then the sum-of-squares (sum(Yi^2)) has a chi-square distribution with k degrees of freedom.

The expected value of this distribution is k. Chi_square with parameter k is gamma-distributed with alpha=k/2, beta=2.

Generation is using relationship to gamma distribution.

Parameters
kdegrees of freedom, k>0
rngthe underlying random number generator

Referenced by cComponent::chi_square().

◆ student_t()

SIM_API double omnetpp::student_t ( cRNG rng,
unsigned int  i 
)

Returns a random variate from the student-t distribution with i degrees of freedom. If Y1 has a normal distribution and Y2 has a chi-square distribution with k degrees of freedom then X = Y1 / sqrt(Y2/k) has a student-t distribution with k degrees of freedom.

Generation is using relationship to gamma and chi-square.

Parameters
idegrees of freedom, i>0
rngthe underlying random number generator

Referenced by cComponent::student_t().

◆ cauchy()

SIM_API double omnetpp::cauchy ( cRNG rng,
double  a,
double  b 
)

Returns a random variate from the Cauchy distribution (also called Lorentzian distribution) with parameters a,b where b>0.

This is a continuous distribution describing resonance behavior. It also describes the distribution of horizontal distances at which a line segment tilted at a random angle cuts the x-axis.

Generation uses inverse transform.

Parameters
a
bb>0
rngthe underlying random number generator

Referenced by cComponent::cauchy().

◆ triang()

SIM_API double omnetpp::triang ( cRNG rng,
double  a,
double  b,
double  c 
)

Returns a random variate from the triangular distribution with parameters a <= b <= c.

Generation uses inverse transform.

Parameters
a,b,ca <= b <= c
rngthe underlying random number generator

Referenced by cComponent::triang().

◆ lognormal()

double omnetpp::lognormal ( cRNG rng,
double  m,
double  w 
)
inline

Returns a random variate from the lognormal distribution with "scale" parameter m and "shape" parameter w. m and w correspond to the parameters of the underlying normal distribution (m: mean, w: standard deviation.)

Generation is using relationship to normal distribution.

Parameters
m"scale" parameter, m>0
w"shape" parameter, w>0
rngthe underlying random number generator

References omnetpp::normal().

Referenced by cComponent::lognormal().

◆ weibull()

SIM_API double omnetpp::weibull ( cRNG rng,
double  a,
double  b 
)

Returns a random variate from the Weibull distribution with parameters a, b > 0, where a is the "scale" parameter and b is the "shape" parameter. Sometimes Weibull is given with alpha and beta parameters, then alpha=b and beta=a.

The Weibull distribution gives the distribution of lifetimes of objects. It was originally proposed to quantify fatigue data, but it is also used in reliability analysis of systems involving a "weakest link," e.g. in calculating a device's mean time to failure.

When b=1, Weibull(a,b) is exponential with mean a.

Generation uses inverse transform.

Parameters
athe "scale" parameter, a>0
bthe "shape" parameter, b>0
rngthe underlying random number generator

Referenced by cComponent::weibull().

◆ pareto_shifted()

SIM_API double omnetpp::pareto_shifted ( cRNG rng,
double  a,
double  b,
double  c 
)

Returns a random variate from the shifted generalized Pareto distribution.

Generation uses inverse transform.

Parameters
a,bthe usual parameters for generalized Pareto
cshift parameter for left-shift
rngthe underlying random number generator

Referenced by cComponent::pareto_shifted().