# Erlang Class Reference

This class simulates an Erlang distribution. More...

#include <Erlang.h>

Inheritance diagram for Erlang:

List of all members.

## 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
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.
double pVariance
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.

## Detailed Description

This class simulates an Erlang distribution.

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 :

Date:
1995-01-01
Changes:
none
Status:
stable

Definition at line 91 of file Erlang.h.

## Constructor & Destructor Documentation

 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.

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.

Parameters:
 mean the initial value for the distribution's mean value from which the distribution's parameters and are calculated. The default mean value is zero. If you use a mean value less than or equal to zero, the distribution's scale factor will be set to "0.5" variance the initial value for the distribution's variance from which the distribution's parameters and are calculated. The default variance is "1"
Returns:
none
Date:
1995-01-01
Changes
none
Status
stable

Definition at line 94 of file Erlang.cpp.

 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 .

Parameters:
 mean the initial value for the distribution's mean value from which the distribution's parameters and are calculated. If you use a mean value less than or equal to zero, the distribution's scale factor will be set to "0.5" variance the initial value for the distribution's variance from which the distribution's parameters and are calculated r the pseudo random number generator that is used
Returns:
none
Date:
1995-01-01
Changes
none
Status
stable

Definition at line 148 of file Erlang.cpp.

## Member Function Documentation

 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 .

Parameters:
 newMean the new value for the distribution's mean value (pMean). If newMean is less than or equal to zero then the distribution's scale factor is set to 0.5.
Returns:
none
Date:
1995-01-01
Changes
none
Status
stable

Definition at line 186 of file Erlang.h.

References pMean.

 double Erlang::mean ( ) const [inline]

Returns the current mean value of the distribution as stored in pMean.

Returns:
the current mean value (pMean)
Date:
1995-01-01
Changes
none
Status
stable

Definition at line 125 of file Erlang.h.

References pMean.

 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.

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 .

Returns:
a random number for the Erlang distribution with order and scale factor based on pMean and pVariance
Date:
1995-01-01
Changes
2002-04-16, ra:
Now checks the distribution's parameters "k" and "a" for validity (both must be greater than zero) and returns zero if at least one parameter is not valid.
Status
stable

Implements RandomVar< double >.

Definition at line 252 of file Erlang.cpp.

 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.

Parameters:
 k the distribution's order. k must be greater than zero, otherwise "0." will be returned a the distribution's scale . a must be greater than zero, otherwise "0." will be returned
Returns:
a random number for the Erlang distribution with order k and scale factor a
Date:
1995-01-01
Changes
2002-04-16, ra:
Now checks the distribution's parameters "k" and "a" for validity (both must be greater than zero) and returns zero if at least one parameter is not valid.
Status
stable

Definition at line 205 of file Erlang.cpp.

References RandomVar< double >::rng.

 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.

Returns:
x the random number for which the occurrence probability is returned. If x is less than zero the probability "0." will be returned
Date:
1995-01-01
Changes
2002-04-16, ra:
Was just a dummy method before. Now it really calculates the probability.
Status
stable

Implements RandomVar< double >.

Definition at line 296 of file Erlang.cpp.

 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 .

Parameters:
 newVar the new value for the distribution's variance (pVariance)
Returns:
none
Date:
1995-01-01
Changes
none
Status
stable

Definition at line 222 of file Erlang.h.

References pVariance.

 double Erlang::variance ( ) const [inline]

Returns the current variance of the distribution as stored in pVariance.

Returns:
the current variance (pVariance)
Date:
1995-01-01
Changes
none
Status
stable

Definition at line 148 of file Erlang.h.

References pVariance.

## Member Data Documentation

 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 .

Definition at line 251 of file Erlang.h.

Referenced by mean().

 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.

Definition at line 260 of file Erlang.h.

Referenced by variance().

The documentation for this class was generated from the following files: