Rosetta Utilities  2014.35
Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
numeric::random::RandomGenerator Class Reference

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 ()
< uniform_RG
createIntNumberGenerator (std::string const &type)

Private Attributes

int seed_offset
< uniform_RG
 Our magic number goes there. More...
bool gaussian_iset
 flags for Gaussian generation More...
double gaussian_gset

Detailed Description

Random number generator system.

Member Typedef Documentation

Constructor & Destructor Documentation

numeric::random::RandomGenerator::RandomGenerator ( )
numeric::random::RandomGenerator::RandomGenerator ( RandomGenerator const &  )
numeric::random::RandomGenerator::RandomGenerator ( int const  magicNumber)
numeric::random::RandomGenerator::~RandomGenerator ( )

Member Function Documentation

vector< RandomGenerator * > & numeric::random::RandomGenerator::allGenerators ( )
static utility::pointer::owning_ptr<uniform_RG> numeric::random::RandomGenerator::createIntNumberGenerator ( std::string const &  type)
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: Numerical Recipes, section 7.2, a.k.a. "GASDEV"
JJG 4/01

References gaussian_gset, gaussian_iset, numeric::log(), and uniform().

Referenced by numeric::random::gaussian(), operator()(), numeric::random::random_rotation_angle(), and numeric::random::random_translation().

int numeric::random::RandomGenerator::get_seed ( )

Return the seed used by this RNG.

References generator.

void numeric::random::RandomGenerator::initializeRandomGenerators ( int const  start_seed,
RND_RunType  run_type,
std::string const &  type = "" 

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.

double numeric::random::RandomGenerator::max ( ) const
double numeric::random::RandomGenerator::min ( ) const
double numeric::random::RandomGenerator::operator() ( )

References gaussian().

template<class T >
T const& numeric::random::RandomGenerator::random_element ( utility::vector1< T > const &  v)

return a random element from a utility::vector1

References random_range().

int numeric::random::RandomGenerator::random_range ( int  low,
int  high 

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().

void numeric::random::RandomGenerator::restoreAllStates ( std::istream &  in)

Restores the state of all random number generators from given stream.

void numeric::random::RandomGenerator::restoreState ( std::istream &  in)
void numeric::random::RandomGenerator::saveAllStates ( std::ostream &  out)

Saves the state of all random number generators to given stream.

void numeric::random::RandomGenerator::saveState ( std::ostream &  out)
void numeric::random::RandomGenerator::set_seed ( int  seed)

Return the seed used by this RNG.

References generator.

double numeric::random::RandomGenerator::uniform ( )

Member Data Documentation

double numeric::random::RandomGenerator::gaussian_gset

Referenced by gaussian().

bool numeric::random::RandomGenerator::gaussian_iset

flags for Gaussian generation

Referenced by gaussian().

utility::pointer::owning_ptr<uniform_RG> numeric::random::RandomGenerator::generator

Our magic number goes there.

Referenced by get_seed(), set_seed(), and uniform().

int numeric::random::RandomGenerator::seed_offset

The documentation for this class was generated from the following files: