![]() |
Rosetta Utilities
2014.16.56682
|
Random number generator system. More...
#include <random.hh>
Public Types | |
| typedef double | result_type |
Public Member Functions | |
| RandomGenerator (int const magicNumber) | |
| ~RandomGenerator () | |
| double | uniform () |
| double | gaussian () |
| Get Gaussian distribution random number. More... | |
| int | random_range (int low, int high) |
| Returns a random int in the range specified by the arguments. More... | |
| int | get_seed () |
| Return the seed used by this RNG. More... | |
| void | set_seed (int seed) |
| Return the seed used by this RNG. More... | |
| void | saveState (std::ostream &out) |
| void | restoreState (std::istream &in) |
| template<class T > | |
| T const & | random_element (utility::vector1< T > const &v) |
| return a random element from a utility::vector1 More... | |
| double | operator() () |
| double | min () const |
| double | max () const |
Static Public Member Functions | |
| static void | initializeRandomGenerators (int const start_seed, RND_RunType run_type, std::string const &type="") |
| static void | saveAllStates (std::ostream &out) |
| Saves the state of all random number generators to given stream. More... | |
| static void | restoreAllStates (std::istream &in) |
| Restores the state of all random number generators from given stream. More... | |
Private Member Functions | |
| RandomGenerator () | |
| RandomGenerator (RandomGenerator const &) | |
Static Private Member Functions | |
| static std::vector < RandomGenerator * > & | allGenerators () |
| static utility::pointer::owning_ptr < uniform_RG > | createIntNumberGenerator (std::string const &type) |
Private Attributes | |
| int | seed_offset |
| utility::pointer::owning_ptr < uniform_RG > | generator |
| Our magic number goes there. More... | |
| bool | gaussian_iset |
| flags for Gaussian generation More... | |
| double | gaussian_gset |
Random number generator system.
|
private |
|
private |
| numeric::random::RandomGenerator::RandomGenerator | ( | int const | magicNumber | ) |
References allGenerators(), utility::io::oc::cerr, and utility_exit.
| numeric::random::RandomGenerator::~RandomGenerator | ( | ) |
References allGenerators(), and basic::options::OptionKeys::begin.
|
staticprivate |
Referenced by RandomGenerator(), and ~RandomGenerator().
|
staticprivate |
| double numeric::random::RandomGenerator::gaussian | ( | ) |
Get Gaussian distribution random number.
SL: this is function is ported from old Rosetta++.
Returns a gaussian random number (normally distributed deviate with zero mean and unit variance) using ran3 as a source of uniform deviates. Always call with the same idum
References gaussian_gset, gaussian_iset, numeric::log(), and uniform().
Referenced by numeric::random::gaussian(), and operator()().
|
inline |
Return the seed used by this RNG.
References generator.
|
static |
init all rundom number generators in program, must be called after main() start executing
References numeric::random::_RND_TestRun_, numeric::random::createRG(), numeric::random::RG, and basic::options::OptionKeys::run::seed_offset.
|
inline |
|
inline |
|
inline |
References gaussian().
|
inline |
return a random element from a utility::vector1
References random_range().
Returns a random int in the range specified by the arguments.
Returns a random int in the range specified by the arguments, with both enpoints being included in the possible output.
References numeric::random::uniform().
Referenced by random_element(), numeric::IntervalSet< double >::random_point(), numeric::random::random_range(), and numeric::random::reservoir_sample().
|
static |
Restores the state of all random number generators from given stream.
| void numeric::random::RandomGenerator::restoreState | ( | std::istream & | in | ) |
References basic::options::OptionKeys::run::seed_offset.
|
static |
Saves the state of all random number generators to given stream.
| void numeric::random::RandomGenerator::saveState | ( | std::ostream & | out | ) |
References basic::options::OptionKeys::run::seed_offset.
|
inline |
Return the seed used by this RNG.
References generator.
|
inline |
Return from range [0, 1] (?) uniform random number
The implementation of random_range leads me to believe this is actually [0, 1), like most other random number generators. -IWD
References generator.
Referenced by gaussian(), numeric::random::random_permutation(), numeric::IntervalSet< double >::random_point(), numeric::random::WeightedSampler::random_sample(), numeric::random::reservoir_sample(), basic::database::safely_read_from_database(), and numeric::random::uniform().
|
private |
Referenced by gaussian().
|
private |
flags for Gaussian generation
Referenced by gaussian().
|
private |
Our magic number goes there.
Referenced by get_seed(), set_seed(), and uniform().
|
private |
1.8.7