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... | |
SIM_API double omnetpp::uniform | ( | cRNG * | rng, |
double | a, | ||
double | b | ||
) |
Returns a random variate with uniform distribution in the range [a,b).
a,b | the interval, a<b |
rng | the underlying random number generator |
Referenced by cComponent::uniform().
SimTime version of uniform(cRNG*,double,double), for convenience.
References SimTime::dbl().
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).
mean | mean value |
rng | the underlying random number generator |
Referenced by cComponent::exponential().
SimTime version of exponential(cRNG*,double), for convenience.
References SimTime::dbl().
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.
mean | mean of the normal distribution |
stddev | standard deviation of the normal distribution |
rng | the underlying random number generator |
Referenced by cComponent::normal().
SimTime version of normal(cRNG*,double,double), for convenience.
References SimTime::dbl().
Referenced by omnetpp::lognormal().
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.
mean | mean of the normal distribution |
stddev | standard deviation of the normal distribution |
rng | the underlying random number generator |
Referenced by cComponent::truncnormal().
SimTime version of truncnormal(cRNG*,double,double), for convenience.
References SimTime::dbl().
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.
alpha | >0 the "shape" parameter |
theta | >0 the "scale" parameter |
rng | the underlying random number generator |
Referenced by cComponent::gamma_d().
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.
alpha1,alpha2 | >0 |
rng | the underlying random number generator |
Referenced by cComponent::beta().
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.
k | number of phases, k>0 |
mean | >0 |
rng | the underlying random number generator |
Referenced by cComponent::erlang_k().
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.
k | degrees of freedom, k>0 |
rng | the underlying random number generator |
Referenced by cComponent::chi_square().
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.
i | degrees of freedom, i>0 |
rng | the underlying random number generator |
Referenced by cComponent::student_t().
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.
a | |
b | b>0 |
rng | the underlying random number generator |
Referenced by cComponent::cauchy().
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.
a,b,c | a <= b <= c |
rng | the underlying random number generator |
Referenced by cComponent::triang().
|
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.
m | "scale" parameter, m>0 |
w | "shape" parameter, w>0 |
rng | the underlying random number generator |
References omnetpp::normal().
Referenced by cComponent::lognormal().
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.
a | the "scale" parameter, a>0 |
b | the "shape" parameter, b>0 |
rng | the underlying random number generator |
Referenced by cComponent::weibull().
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.
a,b | the usual parameters for generalized Pareto |
c | shift parameter for left-shift |
rng | the underlying random number generator |
Referenced by cComponent::pareto_shifted().