MercuryDPM
0.10
|
This is a class that generates random numbers i.e. More...
#include <RNG.h>
Public Member Functions | |
RNG () | |
void | set_RandomSeed (Mdouble new_seed) |
This is the seed for the random number generator. More... | |
Mdouble | get_RN (Mdouble min, Mdouble max) |
This is a random generating routine can be used for initial positions. More... | |
Mdouble | test () |
This function tests the quality of random numbers, based on the chi-squared test. More... | |
void | set_LCGParms (int new_a, int new_c, int new_m) |
This functions set the parameters for the LCG random number generator. It goes multiplier, addition, mod. More... | |
void | randomise () |
sets the random variables such that they differ for each run More... | |
void | set_LFGParms (int new_p, int new_q) |
This function sets the parametes for the LFG random number generator. More... | |
void | set_RNtypeLCG () |
Make the random number generator based on LCG. More... | |
void | set_RNtypeLFG () |
Make the random number generator based on LFG. More... | |
Private Member Functions | |
Mdouble | get_LCG (Mdouble min, Mdouble max) |
This is a basic Linear Congruential Generator Random. More... | |
Mdouble | get_LFG (Mdouble min, Mdouble max) |
This is a Laggend Fibonacci Generator. More... | |
void | seed_LFG () |
This seed the LFG. More... | |
Private Attributes | |
unsigned long int | random_seed_LCG |
This is the initiall seed of the RNG. More... | |
std::vector< Mdouble > | random_seed_LFG |
This is the seeds required for the LFG. More... | |
long int | a |
This are the two parameters that control the LCG random generated. More... | |
long int | c |
long int | m |
long int | p |
This are the parameters that control the LFG random generator. More... | |
long int | q |
int | type |
This is the type of random number generator. More... | |
This is a class that generates random numbers i.e.
named the Random Number Generator (RNG). This is a stand-along class; but is encapsulated (used) by the MD class. To make it architecture safe the both LCG and function is hard codes i.e. does not use the internal C++ one.
|
inline |
Definition at line 42 of file RNG.h.
References a, c, m, p, q, random_seed_LCG, random_seed_LFG, seed_LFG(), and type.
This is a basic Linear Congruential Generator Random.
This is a basic Linear Congruential Generator Random Is described by three parameters, the multiplication a, the addition c and the mod m.
Definition at line 55 of file RNG.cc.
References a, c, m, and random_seed_LCG.
Referenced by get_RN(), and seed_LFG().
This is a Laggend Fibonacci Generator.
This is a basic Linear Fibonacci Generator Random Is described by three parameters, the multiplication a, the addition c and the mod m.
Definition at line 89 of file RNG.cc.
References p, q, and random_seed_LFG.
Referenced by get_RN().
This is a random generating routine can be used for initial positions.
This is a random number generator and returns a Mdouble within the range specified.
{Thomas: This code does sth. when min>max; I would prefer to throw an error.}
{the random seed should be stored in restart}
Definition at line 32 of file RNG.cc.
References get_LCG(), get_LFG(), and type.
Referenced by InsertionBoundary::checkBoundaryActionsBeforeTimeStep(), Chute::create_bottom(), Chute::create_inflow_particle(), ChuteWithHopper::create_inflow_particle(), ChuteBottom::setup_particles_initial_conditions(), and test().
|
inline |
sets the random variables such that they differ for each run
Definition at line 59 of file RNG.h.
References set_RandomSeed().
Referenced by MD::readNextArgument().
|
private |
This seed the LFG.
Definition at line 77 of file RNG.cc.
References get_LCG(), p, and random_seed_LFG.
Referenced by RNG(), set_LFGParms(), and set_RandomSeed().
This function sets the parametes for the LFG random number generator.
Definition at line 172 of file RNG.cc.
References p, q, random_seed_LFG, and seed_LFG().
|
inline |
This is the seed for the random number generator.
Definition at line 46 of file RNG.h.
References random_seed_LCG, and seed_LFG().
Referenced by MD::constructor(), and randomise().
|
inline |
|
inline |
Mdouble RNG::test | ( | ) |
This function tests the quality of random numbers, based on the chi-squared test.
It reports a probabity that the random number being generated are coming from a uniform distributed. If this number is less than 0.95, it is strongly advised that you change the parameters being used
Definition at line 117 of file RNG.cc.
References mathsFunc::chi_squared_prob(), and get_RN().
|
private |
This are the two parameters that control the LCG random generated.
Definition at line 88 of file RNG.h.
Referenced by get_LCG(), RNG(), and set_LCGParms().
|
private |
Definition at line 88 of file RNG.h.
Referenced by get_LCG(), RNG(), and set_LCGParms().
|
private |
Definition at line 88 of file RNG.h.
Referenced by get_LCG(), RNG(), and set_LCGParms().
|
private |
This are the parameters that control the LFG random generator.
Definition at line 91 of file RNG.h.
Referenced by get_LFG(), RNG(), seed_LFG(), and set_LFGParms().
|
private |
Definition at line 91 of file RNG.h.
Referenced by get_LFG(), RNG(), and set_LFGParms().
|
private |
|
private |
This is the seeds required for the LFG.
Definition at line 85 of file RNG.h.
Referenced by get_LFG(), RNG(), seed_LFG(), and set_LFGParms().
|
private |
This is the type of random number generator.
Definition at line 94 of file RNG.h.
Referenced by get_RN(), RNG(), set_RNtypeLCG(), and set_RNtypeLFG().