mxlib
c++ tools for analyzing astronomical data and other tasks by Jared R. Males. [git repo]
|
A random number type, which functions like any other arithmetic type.
Combines a random engine, and a random distribution. Using the type conversion operator randomT returns the next random deviate whenever it is referenced.
Example:
Verify compilation and basic operation of randomT with std::distributions [test doc]
Verify compilation and basic operation of randomT with the Laplace distribution [test doc]
Definition at line 60 of file randomT.hpp.
#include <math/randomT.hpp>
Public Types | |
typedef _randistT | randistT |
Typedef for the distribution type. More... | |
typedef _ranengT | ranengT |
Typedef for the engine type. More... | |
Public Member Functions | |
randomT (bool doSeed=true) | |
Constructor. More... | |
operator typeT () | |
The conversion operator, returns the next value in the sequence, according to the distribution. More... | |
void | seed (typename ranengT::result_type seedval) |
Set the seed of the random engine. More... | |
void | seed () |
Seed the random engine with a good value. More... | |
Public Attributes | |
_randistT | distribution |
The random distribution. More... | |
ranengT | engine |
The random engine. More... | |
typedef _randistT mx::math::randomT< typeT, _ranengT, _randistT >::randistT |
Typedef for the distribution type.
Definition at line 66 of file randomT.hpp.
typedef _ranengT mx::math::randomT< typeT, _ranengT, _randistT >::ranengT |
Typedef for the engine type.
Definition at line 69 of file randomT.hpp.
|
inline |
Constructor.
By default this calls the seed method, which will use /dev/random to seed the generator on linux, and time(0) on other systems. Set to false to suppress seeding, and/or set a seed with seed(x).
[in] | doSeed | [optional] if true then the seed method is called upon construction. |
Definition at line 75 of file randomT.hpp.
References mx::math::randomT< typeT, _ranengT, _randistT >::seed().
|
inline |
The conversion operator, returns the next value in the sequence, according to the distribution.
Definition at line 87 of file randomT.hpp.
|
inline |
Seed the random engine with a good value.
Calls mx::randomSeed to get the value. On linux this uses /dev/urandom. On other sytems, this uses time(0).
Definition at line 104 of file randomT.hpp.
References mx::math::randomSeed().
Referenced by mx::math::randomT< typeT, _ranengT, _randistT >::randomT().
|
inline |
Set the seed of the random engine.
Calls the engines seed member function.
[in] | seedval | the argument to pass to ranengT::seed() |
Definition at line 96 of file randomT.hpp.
References mx::math::randomT< typeT, _ranengT, _randistT >::engine.
Referenced by mx::AO::influenceFunctionsGaussian(), and SCENARIO().
_randistT mx::math::randomT< typeT, _ranengT, _randistT >::distribution |
The random distribution.
Definition at line 81 of file randomT.hpp.
Referenced by mx::math::randomT< int, std::mt19937_64, std::poisson_distribution< int > >::operator int().
ranengT mx::math::randomT< typeT, _ranengT, _randistT >::engine |
The random engine.
Definition at line 84 of file randomT.hpp.
Referenced by mx::math::randomT< int, std::mt19937_64, std::poisson_distribution< int > >::operator int(), and mx::math::randomT< typeT, _ranengT, _randistT >::seed().