#include <Erlang.h>
Public Member Functions | |
Erlang (double mean=0, double variance=1) | |
Creates a new Erlang random generator instance and initializes the mean value and the variance of the distribution. | |
Erlang (double mean, double variance, RNG &r) | |
Creates a new Erlang random generator instance by using the pseudo random number generator "r" for the determination of random values and initializes the mean value and the variance of the distribution. | |
double | mean () const |
Returns the current mean value of the distribution as stored in pMean. | |
double | variance () const |
Returns the current variance of the distribution as stored in pVariance. | |
void | mean (double newMean) |
Sets the current mean value of the distribution as stored in pMean to the new value "newMean". | |
void | variance (double newVar) |
Sets the current variance of the distribution as stored in pVariance to the new value "newVar". | |
double | operator() (unsigned k, double a) |
Returns an Erlang random number for the distribution with order "k" and scale factor "a". | |
double | operator() () |
Returns an Erlang random number for the distribution with order and scale factor that are calculated from the preset mean value pMean and variance pVariance. | |
double | p (const double &) const |
Returns the probability for the occurrence of random number "x" for the Erlang distribution with order and scale factor calculated from the preset mean value pMean and variance pVariance. | |
Protected Attributes | |
double | pMean |
double | pVariance |
This class is derived from class RandomVar and the uniformally distributed pseudo random number values of the interval (0,1) are transformed to type "double" of the Erlang distribution.
The Erlang distribution is more practical than the (Negative) Exponential distribution, taking into account, that many processes need a minimum time. For this, the Erlang distribution has an additional parameter , known as "the order" of the distribution. For every
there is an Erlang distribution, with the orders
being relevant in practice.
The greater the more improbable are short times and the less the standard deviation is.
For the Erlang distribution is identical to the (Negative) Exponential distribution (see NegExponential).
The Erlang distribution is given by:
for the scale and the order
.
Below you can see the distribution for the parameter for the distributions with the orders
:
Erlang::Erlang | ( | double | mean = 0 , |
|
double | variance = 1 | |||
) |
Creates a new Erlang random generator instance and initializes the mean value and the variance of the distribution.
Creates a new Erlang random generator instance and initializes the mean value and the variance of the distribution.
The distribution's mean value , that is stored in pMean is initialized by mean and the distribution's variance
, that is stored in pVariance is initialized by variance.
Then the mean value and the variance are used to calculate the distribution's order by
and the distribution's scale factor
by
.
will always be an integer value
and
will always be a real number
.
If you are calling this constructor with the default values mean = 0 and variance = 1, then the distribution's order will be the default value and the scale factor will be the default value
.
For this instance, the default pseudo random number generator as member of class RandomVar is used.
mean | the initial value for the distribution's mean value ![]() ![]() ![]() ![]() | |
variance | the initial value for the distribution's variance ![]() ![]() ![]() |
Erlang::Erlang | ( | double | mean, | |
double | variance, | |||
RNG & | r | |||
) |
Creates a new Erlang random generator instance by using the pseudo random number generator "r" for the determination of random values and initializes the mean value and the variance of the distribution.
Creates a new Erlang random generator instance by using the pseudo random number generator "r" for the determination of random values and initializes the mean value and the variance of the distribution.
Each instance of an Erlang random number generator is based on a generator, that is defined in class RNG and returns uniformally pseudo random numbers of the interval (0,1). By default, this is a global generator named RNG::globalRng and included as member in class RandomVar.
Here another pseudo random number generator r is used instead.
Additionally to defining the used pseudo random number generator, the distribution's mean value , that is stored in pMean is initialized by mean and the distribution's variance
, that is stored in pVariance is initialized by variance.
Then the mean value and the variance are used to calculate the distribution's order by
and the distribution's scale factor
by
.
will always be an integer value
and
will always be a real number
.
mean | the initial value for the distribution's mean value ![]() ![]() ![]() ![]() | |
variance | the initial value for the distribution's variance ![]() ![]() ![]() | |
r | the pseudo random number generator that is used |
double Erlang::mean | ( | ) | const [inline] |
double Erlang::variance | ( | ) | const [inline] |
void Erlang::mean | ( | double | newMean | ) | [inline] |
Sets the current mean value of the distribution as stored in pMean to the new value "newMean".
The distribution's mean value is set to newMean and then the distribution's order
and scale factor
are recalculated, because this calculation is based on the mean value.
The distribution's order is defined by
, where
is the distribution's variance as stored in pVariance. The mean value is also used to calculate the scale factor
by
.
will always be an integer value
and
will always be a real number
.
newMean | the new value for the distribution's mean value ![]() ![]() |
void Erlang::variance | ( | double | newVar | ) | [inline] |
Sets the current variance of the distribution as stored in pVariance to the new value "newVar".
The distribution's mean value is set to newVar and then the distribution's order
and scale factor
are recalculated, because this calculation is based on the variance.
The distribution's order is defined by
, where
is the distribution's mean value as stored in pMean. This order is then used to calculate the scale factor
by
.
will always be an integer value
and
will always be a real number
.
newVar | the new value for the distribution's variance ![]() |
double Erlang::operator() | ( | unsigned | k, | |
double | a | |||
) |
Returns an Erlang random number for the distribution with order "k" and scale factor "a".
Returns an Erlang random number for the distribution with order "k" and scale factor "a".
This method performs the inverse transformation of the original uniformally distributed random numbers of the interval (0,1) created by the used pseudo random number generator to the type of the Erlang distribution.
k | the distribution's order. k must be greater than zero, otherwise "0." will be returned | |
a | the distribution's scale ![]() |
double Erlang::operator() | ( | ) | [virtual] |
Returns an Erlang random number for the distribution with order and scale factor that are calculated from the preset mean value pMean and variance pVariance.
Returns an Erlang random number for the distribution with order and scale factor that are calculated from the preset mean value pMean and variance pVariance.
The mean value as stored in pMean and the variance
as stored in pVariance are used to calculate the distribution's order
by
and the distribution's scale factor
by
.
will always be an integer value
and
will always be a real number
.
If you are calling this operator with a preset mean value , then the distribution's order will be the default value
and the scale factor will be the default value
.
Implements RandomVar< double >.
double Erlang::p | ( | const double & | x | ) | const [virtual] |
Returns the probability for the occurrence of random number "x" for the Erlang distribution with order and scale factor calculated from the preset mean value pMean and variance pVariance.
Returns the probability for the occurrence of random number "x" for the Erlang distribution with order and scale factor calculated from the preset mean value pMean and variance pVariance.
The mean value as stored in pMean and the variance
as stored in pVariance are used to calculate the distribution's order
by
and the distribution's scale factor
by
.
will always be an integer value
and
will always be a real number
.
If you are calling this method with a preset mean value , then the distribution's order will be the default value
and the scale factor will be the default value
.
For the Erlang distribution with the calculated mean value and variance, the occurrence probability of random number x is then returned.
Implements RandomVar< double >.
double Erlang::pMean [protected] |
The distribution's mean value , that is used to calculate the distribution's order
by
, where
is the distribution's variance as stored in pVariance. The mean value is also used to calculate the scale factor
by
.
double Erlang::pVariance [protected] |
The distribution's variance value , that is used to calculate the distribution's order
by
, where
is the distribution's mean value as stored in pMean. Because the scale factor
is calculated by
, the variance is also used for the calculation of this factor.