A class that can be used to generate sequences of random numbers according to a number of different algorithms.
More...
|
| Random (Algorithm algorithm=MT19937, unsigned long seed=1) |
| Creates a random number generator that uses the given algorithm to produce random numbers, and seeds it with the specified value.
|
|
| Random (std::string const &algorithm, unsigned long seed=1) |
| Creates a random number generator that uses the algorithm with the given name to produce random numbers, and seeds it with the specified value.
|
|
| Random (Random const &)=default |
|
| Random (Random &&)=default |
|
Random & | operator= (Random const &)=default |
|
Random & | operator= (Random &&)=default |
|
| ~Random ()=default |
|
Random | deepCopy () const |
| Creates a deep copy of this random number generator.
|
|
State | getState () const |
|
void | setState (State const &state) |
|
std::size_t | getStateSize () const |
|
Algorithm | getAlgorithm () const |
|
std::string | getAlgorithmName () const |
|
unsigned long | getSeed () const |
|
double | uniform () |
| Returns a uniformly distributed random double precision floating point number from the generator.
|
|
double | uniformPos () |
| Returns a uniformly distributed random double precision floating point number from the generator.
|
|
unsigned long | uniformInt (unsigned long n) |
| Returns a uniformly distributed random integer from 0 to n-1 .
|
|
double | flat (double const a, double const b) |
| Returns a random variate from the flat (uniform) distribution on [a , b ).
|
|
double | gaussian () |
| Returns a gaussian random variate with mean 0 and standard deviation 1
|
|
double | chisq (double const nu) |
| Returns a random variate from the chi-squared distribution with nu degrees of freedom.
|
|
double | poisson (double const mu) |
| Returns a random variate from the poisson distribution with mean mu .
|
|
A class that can be used to generate sequences of random numbers according to a number of different algorithms.
Support for generating random variates from the uniform, Gaussian, Poisson, and chi-squared distributions is provided.
This class is a thin wrapper for the random number generation facilities of GSL, which supports many additional distributions that can easily be added to this class as the need arises.
- See also
- Random number generation in GSL
-
Random number distributions in GSL
Definition at line 57 of file Random.h.
Accessors for the opaque state of the random number generator.
These may be used to save the state and restore it later, possibly after persisting. The state is algorithm-dependent, and possibly platform/architecture dependent; it should only be used for debugging perposes.
We use string here because it's a format Python and afw::table understand; the actual value is a binary blob that is not expected to be human-readable.
Definition at line 154 of file Random.h.
double lsst::afw::math::Random::uniform |
( |
| ) |
|
Returns a uniformly distributed random double precision floating point number from the generator.
The random number will be in the range [0, 1); the range includes 0.0 but excludes 1.0. Note that some algorithms will not produce randomness across all mantissa bits - choose an algorithm that produces double precisions results (such as Random::RANLXD1, Random::TAUS, or Random::MT19937) if this is important.
- Returns
- a uniformly distributed random double precision floating point number in the range [0, 1).
- See also
- uniformPositiveDouble()
Definition at line 146 of file Random.cc.
unsigned long lsst::afw::math::Random::uniformInt |
( |
unsigned long | n | ) |
|
Returns a uniformly distributed random integer from 0
to n-1
.
This function is not intended to generate values across the full range of unsigned integer values [0, 2^32 - 1]. If this is necessary, use a high precision algorithm like Random::RANLXD1, Random::TAUS, or Random::MT19937 with a minimum value of zero and call get() directly.
- Parameters
-
[in] | n | specifies the range of allowable return values (0 to n-1 ) |
- Returns
- a uniformly distributed random integer
- Exceptions
-
- See also
- get()
-
getMin()
-
getMax()
Definition at line 150 of file Random.cc.
double lsst::afw::math::Random::uniformPos |
( |
| ) |
|
Returns a uniformly distributed random double precision floating point number from the generator.
The random number will be in the range (0, 1); the range excludes both 0.0 and 1.0. Note that some algorithms will not produce randomness across all mantissa bits - choose an algorithm that produces double precisions results (such as Random::RANLXD1, Random::TAUS, or Random::MT19937) if this is important.
- Returns
- a uniformly distributed random double precision floating point number in the range (0, 1).
Definition at line 148 of file Random.cc.