#include <Uniform.h>
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 |
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
.
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.
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" |
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.
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 |
double Uniform::low | ( | ) | const [inline] |
double Uniform::high | ( | ) | const [inline] |
void Uniform::low | ( | double | lo | ) | [inline] |
void Uniform::high | ( | double | hi | ) | [inline] |
double Uniform::operator() | ( | double | lo, | |
double | hi | |||
) | [inline] |
Returns a uniformally distributed random number from the interval ["lo", "hi"[.
A random number with
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.
lo | the minimum random number that can be returned | |
hi | the upper bound for random numbers that can be returned |
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 with pLow
pHigh is returned.
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 is returned, where the interval length is given by pHigh - pLow. If x is not a member of the interval, "0" is returned instead.
Implements RandomVar< double >.
double Uniform::pLow [protected] |
double Uniform::pHigh [protected] |