Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

simth::ExponentialMaxLimitRng Class Reference

Random generator for exponentially distributed variates with an upper interval bound for the generated values ("truncated exponential"). More...

#include <phrand.h>

Inheritance diagram for simth::ExponentialMaxLimitRng:

simth::RandomGeneratorGsl simth::RandomGenerator List of all members.

Public Member Functions

 ExponentialMaxLimitRng (double lambda, double Tmax)
virtual ~ExponentialMaxLimitRng ()
virtual double get () const
double attenuationFactor () const
double maxLimit () const

Detailed Description

Random generator for exponentially distributed variates with an upper interval bound for the generated values ("truncated exponential").

With given attenuation $\lambda $ and an upper interval bound $T$ the probability density function (pdf) of this random variable will be

\[ f(x) = \left\{ \begin{array}{cl} 0 & \mbox{for } x<0, x>T \\ \frac{\lambda}{1-e^{-\lambda T}} e^{-\lambda x} & \mbox{for }0\le x\le T \end{array} \right. \]

The attenuation lambda and the upper interval bound T are given as constructor parameters.

For this truncated exponential, the mean value is

\[\mu_{tr}=\frac{1}{\lambda} - T\frac{1}{e^{\lambda T}-1}\]

(note the positive exponent in the denominator) and the variance is

\[ \sigma_{tr}^2 = \frac{1}{\lambda^2} - (T^2+\frac{T}{\lambda})\frac{1}{e^{\lambda T}-1}\]

The cumulative distribution function (CDF) is

\[ F(x) = \int_{-\infty}^xf(t)dt = \left\{ \begin{array}{cl} 0 & \mbox{for }x<0 \\ \frac{1}{1-e^{-\lambda T}}(1-e^{-\lambda x}) & \mbox{for }0\le x\le T \\ 1 & \mbox{for }x>T \end{array} \right. \]

This PDF of a truncated exponential will approximately come close to the usual non-truncated exponential if the upper interval bound T is greater than roughly 6.5 times the mean value, i.e. if the condition $T>6.5\cdot1/\lambda$ holds. This bound is derived by calculating how much greater T must be compared to $\lambda$, so that the second term of the mean value $\mu_{tr}$ is smaller than a given fraction of the first term. The required multiple turns out to be calculated by the -1th branch of Lambert's W function of the precision, e.g. for 0.01 in Matlab -lambert(-1,-0.01)

If this condition is met, the usual formulas for the exponential distribution will hold: The probability density function (pdf) is $p(x)=\lambda e^{-\lambda x}$ for $x>0$ and $p(x)=0$ elsewhere, the mean value is $\mu=1/\lambda$, and the variance is $\sigma^2=1/\lambda^2$.

WATCH OUT: The constructor takes the attenuation as an argument, not the mean value. Even in earlier versions, when the documentation errornously said it would take the mean, it still took the attenuation. Please make really sure you understand that you have to specify the attenuation here and not the mean.

This RNG simply uses a uniform RNG from the GSL, and takes this as input to the inverse cumulative distribution function (CDF) of the truncated exponential CDF. This means if $y$ is a [0,1[-uniform random variable, the truncated exponential random variable $x$ is calculated as

\[ x = F^{-1}(y) = -\frac{1}{\lambda}\ln\left(1-y(1-e^{-\lambda T})\right) \]

Previously it was stated here that the 'maximally equidistributed combined Tausworthe generator by L'Ecuyer' is used to generator the random output. (See GSL reference manual for further information).


Constructor & Destructor Documentation

simth::ExponentialMaxLimitRng::ExponentialMaxLimitRng double  lambda,
double  Tmax
 

Class constructor with attenuation factor 'lambda' and maximal generated value 'T'.

Parameters:
lambda Attenuation factor. This is approximately 1/mean.
Tmax Upper interval bound for generated values. The distribution approximates a non-truncated exponential as soon as Tmax is greater than roughly 6.5 times the mean value (=1/attenuation).

virtual simth::ExponentialMaxLimitRng::~ExponentialMaxLimitRng  )  [virtual]
 

Destructor


Member Function Documentation

virtual double simth::ExponentialMaxLimitRng::get  )  const [virtual]
 

Returns a random variate with the described exponential distribution.

Implements simth::RandomGenerator.

double simth::ExponentialMaxLimitRng::attenuationFactor  )  const [inline]
 

Attenuation factor (lambda) of the distribution (approx. = 1/mean).

double simth::ExponentialMaxLimitRng::maxLimit  )  const [inline]
 


Generated on Mon Aug 15 13:54:39 2005 for simthetic by  doxygen 1.4.1