Rosetta
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 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::VirtualBase
 VirtualBase ()=default
 Default constructor. More...
 
virtual ~VirtualBase ()=default
 The virtual destructor is one of the main reasons for the VirtualBase class. More...
 
 VirtualBase (VirtualBase const &)=default
 
 VirtualBase (VirtualBase &&)=default
 
VirtualBaseoperator= (VirtualBase const &)=default
 
VirtualBaseoperator= (VirtualBase &&)=default
 

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

◆ result_type

Constructor & Destructor Documentation

◆ RandomGenerator() [1/2]

numeric::random::RandomGenerator::RandomGenerator ( )
private

◆ RandomGenerator() [2/2]

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

◆ ~RandomGenerator()

numeric::random::RandomGenerator::~RandomGenerator ( )
overridedefault

Member Function Documentation

◆ gaussian()

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(), uniform(), oop_scan::v1, and oop_scan::v2.

Referenced by fit_helix_in_map(), numeric::random::gaussian(), gaussian_angle_move(), jitter_and_minimize(), jitterloop(), operator()(), perturb_and_rescore(), perturb_bb_and_relax(), UniformPerturber::perturb_chain(), numeric::random::random_point_on_unit_sphere(), numeric::random::random_rotation_angle(), numeric::random::random_translation(), sample_near_current_torsion(), sample_near_nucleoside_torsion(), sample_near_suite_torsion(), and update_torsion_set().

◆ get_seed()

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

Return the seed used by this RNG.

References generator_.

Referenced by apps::pilot::KicSandbox::KicSandbox(), main(), and OutputManager::write_header().

◆ initialized()

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_.

◆ max()

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

◆ min()

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

◆ operator()()

double numeric::random::RandomGenerator::operator() ( )
inline

References gaussian().

◆ random_element()

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(), and kmeans_adaptive_kernel_density_bb_dependent_rotlib::v.

Referenced by erraser_monte_carlo(), and random_element().

◆ random_range()

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

◆ random_range2()

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

◆ restoreState()

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

◆ saveState()

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

◆ set_seed() [1/2]

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

Return the seed used by this RNG.

References generator_.

◆ set_seed() [2/2]

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 devel_main(), PerformanceBenchmark::execute(), basic::random::init_random_generators(), main(), and protocols_main().

◆ uniform()

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 TorsionVectorMover::apply(), LoopHashRelax_Sampler::apply(), CenRotCanonicalMover::apply(), create_random_angle_from_range(), create_random_angle_from_range_list(), create_random_nucleoside_torsion(), create_random_suite_torsion(), create_random_torsions(), double_helix_test(), fit_helix_in_map(), gaussian(), gen_pep_bb_frag(), gen_pep_bb_frag_old(), gen_pep_bb_rama(), gen_pep_bb_sequential(), helix_ST(), initialize_free_and_fixed(), jitter_and_minimize(), kinclose(), lariat_modeling(), main(), make_random_perturbation(), MC_run(), metropolis_criterion(), mutate_random_residue(), my_main(), one_chain_MC_sampling(), one_chain_ST_MC(), perturb_and_rescore(), perturb_bb_and_relax(), UniformPerturber::perturb_chain(), myspace::Scheduler::pick_hashing_res(), numeric::random::pick_random_index_from_cdf(), randangle(), random_angle(), random_delta(), numeric::random::random_permutation(), numeric::IntervalSet< T >::random_point(), numeric::random::WeightedSampler::random_sample(), repack_cluster(), numeric::random::reservoir_sample(), myspace::Scheduler::run_combine(), myspace::Scheduler::run_NM(), run_pep_prep(), RunPepSpec(), sample_near_current_torsion(), sample_near_nucleoside_torsion(), sample_near_suite_torsion(), ConstraintToolMover::show_cstset(), simple_loop_modeling_test(), simple_opte_test(), SomeThing::SomeThing(), test(), myspace::test_bbgauss(), myspace::test_loophash(), numeric::random::uniform(), and update_torsion_set().

Friends And Related Function Documentation

◆ rg

RandomGenerator& rg ( )
friend

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

Member Data Documentation

◆ gaussian_gset_

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

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

◆ gaussian_iset_

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

data for Gaussian generation

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

◆ generator_

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

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