Rosetta  2020.11
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
numeric::random::RandomGenerator Class Reference

Random number generator system. More...

#include <random.hh>

Inheritance diagram for numeric::random::RandomGenerator:
Inheritance graph
[legend]

Public Types

typedef double result_type
 
- Public Types inherited from utility::pointer::ReferenceCount
typedef platform::Size Size
 
typedef platform::Size size_type
 

Public Member Functions

 ~RandomGenerator () override
 
bool initialized () const
 Return whether the RandomGenerator has been initialized (by a call to set_seed) More...
 
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 random_range2 (int low, int high)
 Returns a random int in the range specified by the arguments If low == high, it will return the given integer to simplify code using this. s. More...
 
int get_seed () const
 Return the seed used by this RNG. More...
 
void set_seed (std::string const &generator_type, int seed)
 Set the seed and the generator type synchronously. Currently the two supported generator types are "standard" and "mt19937" with the latter being the recommended form. 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. What is this function doing inside the RandomGenerator class? More...
 
double operator() ()
 
double min () const
 
double max () const
 
- Public Member Functions inherited from utility::pointer::ReferenceCount
 ReferenceCount ()
 Default constructor. More...
 
virtual ~ReferenceCount ()
 

Private Member Functions

 RandomGenerator ()
 
 RandomGenerator (RandomGenerator const &)
 

Private Attributes

uniform_RG_OP generator_
 
bool gaussian_iset_
 data for Gaussian generation More...
 
double gaussian_gset_
 

Friends

RandomGeneratorrg ()
 Return the one-per-thread "singleton" random generator. More...
 

Detailed Description

Random number generator system.

Member Typedef Documentation

Constructor & Destructor Documentation

numeric::random::RandomGenerator::RandomGenerator ( )
private
numeric::random::RandomGenerator::RandomGenerator ( RandomGenerator const &  )
private
numeric::random::RandomGenerator::~RandomGenerator ( )
overridedefault

Member Function Documentation

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"
Author
JJG 4/01

References gaussian_gset_, gaussian_iset_, numeric::log(), and uniform().

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

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

Return the seed used by this RNG.

References generator_.

bool numeric::random::RandomGenerator::initialized ( ) const

Return whether the RandomGenerator has been initialized (by a call to set_seed)

The RNG has not been intiliaed if the generator_ object points at null.

References generator_.

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

References gaussian().

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

return a random element from a utility::vector1. What is this function doing inside the RandomGenerator class?

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.

Author
XA

References basic::options::OptionKeys::relax::range::range, erraser_analysis::temp, and numeric::random::uniform().

Referenced by main(), random_element(), numeric::IntervalSet< double >::random_point(), numeric::random::random_range(), random_range2(), and numeric::random::reservoir_sample().

int numeric::random::RandomGenerator::random_range2 ( int  low,
int  high 
)

Returns a random int in the range specified by the arguments If low == high, it will return the given integer to simplify code using this. s.

Author
JAB - Editing random_range produced huge integration test changes, so this is the result. If you have a better name, please change this.

References random_range().

void numeric::random::RandomGenerator::restoreState ( std::istream &  in)
void numeric::random::RandomGenerator::saveState ( std::ostream &  out)
void numeric::random::RandomGenerator::set_seed ( std::string const &  generator_type,
int  seed 
)

Set the seed and the generator type synchronously. Currently the two supported generator types are "standard" and "mt19937" with the latter being the recommended form.

References numeric::random::createRG(), and generator_.

Referenced by PerformanceBenchmark::execute(), and basic::random::init_random_generators().

void numeric::random::RandomGenerator::set_seed ( int  seed)

Return the seed used by this RNG.

References generator_.

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

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 fit_helix_in_map(), gaussian(), gen_pep_bb_sequential(), mutate_random_residue(), numeric::random::pick_random_index_from_cdf(), numeric::random::random_permutation(), numeric::IntervalSet< double >::random_point(), numeric::random::WeightedSampler::random_sample(), numeric::random::reservoir_sample(), run_pep_prep(), RunPepSpec(), and numeric::random::uniform().

Friends And Related Function Documentation

RandomGenerator& rg ( )
friend

Return the one-per-thread "singleton" random generator.

Member Data Documentation

double numeric::random::RandomGenerator::gaussian_gset_
private

Referenced by gaussian(), restoreState(), and saveState().

bool numeric::random::RandomGenerator::gaussian_iset_
private

data for Gaussian generation

Referenced by gaussian(), restoreState(), and saveState().

uniform_RG_OP numeric::random::RandomGenerator::generator_
private

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