Uniform Class Reference

This class simulates a "uniform distribution". More...

#include <Uniform.h>

Inheritance diagram for Uniform:

RandomVar< double >

List of all members.

Public Member Functions

 Uniform (double lo=0, double hi=1)
 Creates a new instance of the uniform random number generator and initializes the lower and upper bound.
 Uniform (double lo, double hi, RNG &r)
 Creates a new 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.
double low () const
 Returns the lower (included) bound pLow for the random numbers interval.
double high () const
 Returns the upper (excluded) bound pHigh for the random numbers interval.
void low (double lo)
 Sets the lower (included) bound pLow for the random numbers interval to the new value "lo".
void high (double hi)
 Sets the upper (excluded) bound pHigh for the random numbers interval to the new value "hi".
double operator() (double lo, double hi)
 Returns a uniformally distributed random number from the interval ["lo", "hi"[.
double operator() ()
 Returns a uniformally distributed random number from the interval [pLow, pHigh[.
double p (const double &) const
 Returns the probability for the occurrence of random number "x".

Protected Attributes

double pLow
double pHigh


Detailed Description

This class simulates a "uniform distribution".

This class is derived from class RandomVar and the random values returned by it are of type "double" but instead of the pseudo random numbers of class RandomVar, the random numbers here are from the interval $[$pLow, pHigh$[$.

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

Constructor & Destructor Documentation

Uniform::Uniform ( double  lo = 0,
double  hi = 1 
)

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

Creates a new instance of the 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

Uniform::Uniform ( double  lo,
double  hi,
RNG r 
)

Creates a new 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 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 uniform random number generator is based on a "real" random number generator, that is defined in class RNG and returns random numbers in the interval (0,1). Normally this is a global generator named RNG::globalRng. The random values returned by this "real" random number generator are then transformed into the type of the uniform random number generator (double).
See classes RNG and RandomVar for details.
Additionally to defining the used "real" 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

double Uniform::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

double Uniform::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 Uniform::low ( double  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 Uniform::high ( double  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

double Uniform::operator() ( double  lo,
double  hi 
) [inline]

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

A random number $rn$ with $lo \leq rn < hi$ is returned, i.e. the original uniformally distributed random numbers of the interval (0,1) created by the used pseudo random number generator are transformed to numbers of the specified interval.

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

double Uniform::operator() (  )  [virtual]

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

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

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

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

Implements RandomVar< double >.

double Uniform::p ( const double &  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. 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< double >.


Member Data Documentation

double Uniform::pLow [protected]

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

double Uniform::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:53 2008 for Dolphin by  doxygen 1.5.6