Rosetta 3.3
Classes | Typedefs | Enumerations | Functions | Variables
numeric::random Namespace Reference

Classes

class  mt19937_RG
class  RandomGenerator
 Random number generator system. More...
class  ReservoirSampler
 Simple container for keeping K random values. More...
class  uniform_RG
 Uniform random number generator. More...
class  standard_RG
 Generator based on rand() < clib > function. More...
class  WeightedSampler

Typedefs

typedef platform::Size Size
typedef
utility::pointer::owning_ptr
< uniform_RG
uniform_RG_OP
typedef
utility::pointer::owning_ptr
< uniform_RG const > 
uniform_RG_COP

Enumerations

enum  RND_RunType { _RND_NormalRun_, _RND_TestRun_ }
 Different type of initialization scheme: _RND_NormalRun_ - all instances of RandomGenerator will be pointing to just one generator. This is main production mode. We do not use multiple generators here because putting many generators will effectively produce long-range correlations between random numbers obtained from different places of program. (By using N generators instead of one we effectively reducing dimensionality of random generator by at least N. Now take in to account number of nodes in computer cluster and its look like we can quickly run in to trouble even with 600 dimensional Mersenne twister.) Somewhat helpful presentation on this topic: "Don't Trust Parallel Monte Carlo!" by Peter Hellekalek, available online at: http://random.mat.sbg.ac.at/~peter/pads98.ps. More...

Functions

static void lshift128 (w128_t *out, const w128_t *in, int shift)
static uint32_t ini_func1 (uint32_t x)
static uint32_t ini_func2 (uint32_t x)
static int sfmt_idxof (int i)
static void do_recursion (w128_t *r, w128_t *a, w128_t *b, w128_t *c, w128_t *lung)
double uniform (void)
double gaussian (void)
int random_range (int low, int high)
uniform_RGcreateRG (string const &type)
 uniform_RG factory
template<class T >
T const & random_element (utility::vector1< T > const &v)
 return a random element from a utility::vector1
template<class T >
void random_permutation (utility::vector1< T > &vect, RandomGenerator &rg)
template<class T >
void random_permutation (utility::vector0< T > &vect, RandomGenerator &rg)
template<class T >
void random_permutation (std::vector< T > &vect, RandomGenerator &rg)
template<typename RandomAccessIterator >
void random_permutation (RandomAccessIterator first, RandomAccessIterator last, RandomGenerator &rg)
 randomly shuffle elements of a sequence
numeric::Real reservoir_sample_accept_prob (numeric::Size n_wanted, numeric::Size const n_seen)
 Returns the probability that the Nth value in a sequence should be accepted using the reservoir sampling criterion.
template<typename T >
utility::vector1< T > reservoir_sample (utility::vector1< T > const &vec, numeric::Size const n_wanted, RandomGenerator &rg)

Variables

RandomGenerator RG (0)

Typedef Documentation


Enumeration Type Documentation

Different type of initialization scheme: _RND_NormalRun_ - all instances of RandomGenerator will be pointing to just one generator. This is main production mode. We do not use multiple generators here because putting many generators will effectively produce long-range correlations between random numbers obtained from different places of program. (By using N generators instead of one we effectively reducing dimensionality of random generator by at least N. Now take in to account number of nodes in computer cluster and its look like we can quickly run in to trouble even with 600 dimensional Mersenne twister.) Somewhat helpful presentation on this topic: "Don't Trust Parallel Monte Carlo!" by Peter Hellekalek, available online at: http://random.mat.sbg.ac.at/~peter/pads98.ps.

_RND_TestRun_ - each instance of RandomGenerator will have its own generator with its own seed. We using this approach because we trying to increase stability of unit test / performance tests / scientific test. WARNING: This mode design specifically for testing purpose and SHOULD NOT be used in production environment (see comment above).

Enumerator:
_RND_NormalRun_ 
_RND_TestRun_ 

Function Documentation

uniform_RG* numeric::random::createRG ( string const &  type)
static void numeric::random::do_recursion ( w128_t r,
w128_t a,
w128_t b,
w128_t c,
w128_t lung 
) [inline, static]

This function represents the recursion formula.

Parameters:
routput
aa 128-bit part of the internal state array
ba 128-bit part of the internal state array
ca 128-bit part of the internal state array
lunga 128-bit part of the internal state array

References DSFMT_HIGH_CONST, DSFMT_LOW_MASK, DSFMT_MSK1, DSFMT_MSK2, DSFMT_SL1, DSFMT_SL2, DSFMT_SR1, DSFMT_SR2, lshift128(), W128_T::u, and rosetta_py::utility::rankorder::x.

Referenced by numeric::random::mt19937_RG::gen_rand_all().

double numeric::random::gaussian ( void  )
static uint32_t numeric::random::ini_func1 ( uint32_t  x) [inline, static]

This function represents a function used in the initialization by init_by_array

Parameters:
x32-bit integer
Returns:
32-bit integer

Referenced by numeric::random::mt19937_RG::init_by_array().

static uint32_t numeric::random::ini_func2 ( uint32_t  x) [inline, static]

This function represents a function used in the initialization by init_by_array

Parameters:
x32-bit integer
Returns:
32-bit integer

Referenced by numeric::random::mt19937_RG::init_by_array().

static void numeric::random::lshift128 ( w128_t out,
const w128_t in,
int  shift 
) [inline, static]

This function simulates SIMD 128-bit left shift by the standard C. The 128-bit integer given in in is shifted by (shift * 8) bits. This function simulates the LITTLE ENDIAN SIMD.

Parameters:
outthe output of this function
inthe 128-bit data to be shifted
shiftthe shift value

References W128_T::u.

Referenced by do_recursion().

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

return a random element from a utility::vector1

References random_range().

template<class T >
void numeric::random::random_permutation ( utility::vector1< T > &  vect,
RandomGenerator &  rg 
)
template<class T >
void numeric::random::random_permutation ( std::vector< T > &  vect,
RandomGenerator &  rg 
)
template<class T >
void numeric::random::random_permutation ( utility::vector0< T > &  vect,
RandomGenerator &  rg 
)
template<typename RandomAccessIterator >
void numeric::random::random_permutation ( RandomAccessIterator  first,
RandomAccessIterator  last,
RandomGenerator &  rg 
)

randomly shuffle elements of a sequence

References color_pdb::i, and numeric::random::RandomGenerator::uniform().

int numeric::random::random_range ( int  low,
int  high 
)
template<typename T >
utility::vector1< T > numeric::random::reservoir_sample ( utility::vector1< T > const &  vec,
numeric::Size const  n_wanted,
RandomGenerator &  rg 
)
numeric::Real numeric::random::reservoir_sample_accept_prob ( numeric::Size  n_wanted,
numeric::Size const  n_seen 
)

Returns the probability that the Nth value in a sequence should be accepted using the reservoir sampling criterion.

Detailed: If we've seen N values and we want to keep K of them,
the probability of the Nth value being accepted is min(K/N,1.0).

References numeric::min().

Referenced by numeric::random::ReservoirSampler< T >::add_value(), and reservoir_sample().

static int numeric::random::sfmt_idxof ( int  i) [inline, static]

This function simulate a 32-bit array index overlapped to 64-bit array of LITTLE ENDIAN in BIG ENDIAN machine.

References color_pdb::i.

Referenced by numeric::random::mt19937_RG::init_by_array(), and numeric::random::mt19937_RG::setSeed().

double numeric::random::uniform ( void  )

Variable Documentation

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines