DiscreteUniform Class Reference

This class simulates a "uniform distribution" with integer numbers. More...

#include <DiscreteUniform.h>

Inheritance diagram for DiscreteUniform:

RandomVar< long >

List of all members.

Public Member Functions

 DiscreteUniform (long lo=0, long hi=1)
 Creates a new instance of the discrete uniform random number generator and initializes the lower and upper bound.
 DiscreteUniform (long lo, long hi, RNG &rng)
 Creates a new discrete uniform random generator instance by using the pseudo random number generator "r" for the determination of random values and initializes the interval bounds for the random numbers.
long low () const
 Returns the lower (included) bound pLow for the random numbers interval.
long high () const
 Returns the upper (excluded) bound pHigh for the random numbers interval.
void low (long lo)
 Sets the lower (included) bound pLow for the random numbers interval to the new value "lo".
void high (long hi)
 Sets the upper (excluded) bound pHigh for the random numbers interval to the new value "hi".
long operator() (long lo, long hi)
 Returns a uniformally distributed discrete random number from the interval ["lo", "hi"[.
long operator() ()
 Returns a uniformally distributed discrete random number from the interval [pLow, pHigh[.
double p (const long &) const
 Returns the probability for the occurrence of random number "x".

Protected Attributes

long pLow
long pHigh


Detailed Description

This class simulates a "uniform distribution" with integer numbers.

This class is derived from class RandomVar and the uniformally distributed pseudo random number values of the interval (0,1) are transformed to type "long" and are from an interval $[$pLow, pHigh$[$.
This class is similar to class Uniform, but here the distribution is not continuous but discrete, so you will receive integer random numbers instead of double random numbers.

Author:
M. Kreutz
Date:
1995-01-01
Changes:
none
Status:
stable

Constructor & Destructor Documentation

DiscreteUniform::DiscreteUniform ( long  lo = 0,
long  hi = 1 
)

Creates a new instance of the discrete uniform random number generator and initializes the lower and upper bound.

Creates a new instance of the discrete uniform random number generator and initializes the lower and upper bound.

The lower bound pLow and the upper bound pHigh for the interval, from which the random numbers are taken, are initialized.
For this instance, the default pseudo random number generator as member of class RandomVar is used.

Parameters:
lo initial value for the lower bound pLow, by default set to "0"
hi initial value for the upper bound pHigh, by default set to "1"
Returns:
none
Author:
M. Kreutz
Date:
1995-01-01
Changes
none
Status
stable

DiscreteUniform::DiscreteUniform ( long  lo,
long  hi,
RNG r 
)

Creates a new discrete uniform random generator instance by using the pseudo random number generator "r" for the determination of random values and initializes the interval bounds for the random numbers.

Creates a new discrete uniform random generator instance by using the pseudo random number generator "r" for the determination of random values and initializes the interval bounds for the random numbers.

Each instance of a discrete uniform 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 lower and the upper bound for the random numbers interval are initialized.

Parameters:
lo initial value for the lower bound pLow
hi initial value for the upper bound pHigh
r the pseudo random number generator that is used
Returns:
none
Author:
M. Kreutz
Date:
1998-08-17
Changes
none
Status
stable


Member Function Documentation

long DiscreteUniform::low (  )  const [inline]

Returns the lower (included) bound pLow for the random numbers interval.

Returns:
the lower bound pLow of the interval
Author:
M. Kreutz
Date:
1995-01-01
Changes
none
Status
stable

long DiscreteUniform::high (  )  const [inline]

Returns the upper (excluded) bound pHigh for the random numbers interval.

Returns:
the upper bound pHigh of the interval
Author:
M. Kreutz
Date:
1995-01-01
Changes
none
Status
stable

void DiscreteUniform::low ( long  lo  )  [inline]

Sets the lower (included) bound pLow for the random numbers interval to the new value "lo".

Parameters:
lo the new value for the lower bound pLow
Returns:
none
Author:
M. Kreutz
Date:
1995-01-01
Changes
none
Status
stable

void DiscreteUniform::high ( long  hi  )  [inline]

Sets the upper (excluded) bound pHigh for the random numbers interval to the new value "hi".

Parameters:
hi the new value for the upper bound pHigh
Returns:
none
Author:
M. Kreutz
Date:
1995-01-01
Changes
none
Status
stable

long DiscreteUniform::operator() ( long  lo,
long  hi 
) [inline]

Returns a uniformally distributed discrete random number from the interval ["lo", "hi"[.

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 discrete uniform distribution, i.e. a discrete random number $rn$ with $lo \leq rn < hi$ is returned.

Parameters:
lo the minimum random number that can be returned
hi the upper bound for random numbers that can be returned
Returns:
the discrete random number $rn$
Author:
M. Kreutz
Date:
1995-01-01
Changes
none
Status
stable

long DiscreteUniform::operator() (  )  [virtual]

Returns a uniformally distributed discrete random number from the interval [pLow, pHigh[.

Returns a uniformally distributed discrete random number from the interval [pLow, pHigh[.

A discrete random number $rn$ with pLow $\leq rn <$ pHigh is returned.

Returns:
the discrete random number $rn$
Author:
M. Kreutz
Date:
1995-01-01
Changes
none
Status
stable

Implements RandomVar< long >.

double DiscreteUniform::p ( const long &  x  )  const [virtual]

Returns the probability for the occurrence of random number "x".

Returns the probability for the occurrence of random number "x".

The probability $p = \frac{1}{\mbox{interval length}}$ is returned, where the interval length is given by pHigh - pLow + 1. If x is not a member of the interval, "0" is returned instead.

Returns:
the probability $p$ or "0" if x is not an interval member
Author:
M. Kreutz
Date:
1995-01-01
Changes
none
Status
stable

Implements RandomVar< long >.


Member Data Documentation

long DiscreteUniform::pLow [protected]

The lower bound of the random number interval $[$pLow, pHigh$[$.

long DiscreteUniform::pHigh [protected]

The upper bound of the random number interval $[$pLow, pHigh$[$.


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

Generated on Thu Aug 28 18:34:41 2008 for Dolphin by  doxygen 1.5.6