#include <pseudoRandom.h>
Public Member Functions | |
| PseudoRandom () | |
| The default constructor initializes the random number generator with a seed derived from the system clock. | |
| PseudoRandom (Int64 seed) | |
| This constructor sets the seed of the random number generator. | |
| ~PseudoRandom () | |
| The destructor cleans up any allocated resources. | |
| double | gaussian (double mu, double sigma) |
| This member function returns a double drawn from a Gaussian distribution with the specified mean and standard deviation. | |
| Int64 | getCurrentSeed () |
| This member function returns the current state of the random number generator. | |
| double | normal () |
| This member function returns a double drawn from a Gaussian distribution with mean equal to 0.0 and and standard deviation equal to 1.0. | |
| void | setCurrentSeed (Int64 seed) |
| This member function sets the seed for the random number generator. | |
| double | uniform (double lowerBound, double upperBound) |
| This member function returns a double, x, drawn from a uniform distribution with bounds such that:. | |
| int | uniformInt (int lowerBound, int upperBound) |
| This member function returns a integer, x, drawn from a uniform distribution with bounds such that:. | |
Definition at line 30 of file pseudoRandom.h.
| dlr::random::PseudoRandom::PseudoRandom | ( | ) |
The default constructor initializes the random number generator with a seed derived from the system clock.
If you create two PseudoRandom instances with a millisecond or so of each other, you may want to check that they have different seeds by calling the getCurrentSeed() member function.
Definition at line 27 of file pseudoRandom.cpp.
References dlr::portability::getCurrentTime().
| dlr::random::PseudoRandom::PseudoRandom | ( | Int64 | seed | ) |
This constructor sets the seed of the random number generator.
This is useful if you need a repeatable sequence of pseudo-random numbers.
| seed | This argument is a long long integer. Note that currently only the low-order 47 bits are used. The remaining bits are ignored. |
Definition at line 66 of file pseudoRandom.cpp.
References setCurrentSeed().
| dlr::random::PseudoRandom::~PseudoRandom | ( | ) | [inline] |
| double dlr::random::PseudoRandom::gaussian | ( | double | mu, | |
| double | sigma | |||
| ) |
This member function returns a double drawn from a Gaussian distribution with the specified mean and standard deviation.
| mu | This argument specifies the mean of the desired distribution. | |
| sigma | This argument specifies the standard deviation of the desired distribution. |
Definition at line 76 of file pseudoRandom.cpp.
References normal().
| Int64 dlr::random::PseudoRandom::getCurrentSeed | ( | ) |
This member function returns the current state of the random number generator.
Note that the result of this call will change each time a random number is generated. You can pick up at any given place in the sequence of random numbers by recording the seed at that point and setting it later.
Definition at line 87 of file pseudoRandom.cpp.
| double dlr::random::PseudoRandom::normal | ( | ) |
This member function returns a double drawn from a Gaussian distribution with mean equal to 0.0 and and standard deviation equal to 1.0.
Definition at line 103 of file pseudoRandom.cpp.
References dlarnv_().
Referenced by gaussian().
| void dlr::random::PseudoRandom::setCurrentSeed | ( | Int64 | seed | ) |
This member function sets the seed for the random number generator.
This is useful if you need a repeatable sequence of pseudoRandom numbers.
| seed | This argument is a long long integer. Note that currently only the low-order 47 bits are used. The remaining bits are ignored. |
Definition at line 120 of file pseudoRandom.cpp.
Referenced by PseudoRandom().
| double dlr::random::PseudoRandom::uniform | ( | double | lowerBound, | |
| double | upperBound | |||
| ) |
This member function returns a double, x, drawn from a uniform distribution with bounds such that:.
lowerBound <= x < upperBound
| lowerBound | This argument specifies the lower bound of the uniform distribution. | |
| upperBound | This argument specifies the upper bound of the uniform distribution. |
Definition at line 142 of file pseudoRandom.cpp.
References dlarnv_(), and dlr::numeric::range().
Referenced by uniformInt().
| int dlr::random::PseudoRandom::uniformInt | ( | int | lowerBound, | |
| int | upperBound | |||
| ) |
This member function returns a integer, x, drawn from a uniform distribution with bounds such that:.
lowerBound <= x < upperBound
| lowerBound | This argument specifies the lower bound of the uniform distribution. | |
| upperBound | This argument specifies the upper bound of the uniform distribution. |
Definition at line 161 of file pseudoRandom.cpp.
References uniform().
1.5.2