MercuryDPM
Beta
|
This is a class that generates random numbers i.e. named the Random Number Generator (RNG). More...
#include <RNG.h>
Public Member Functions | |
RNG () | |
default constructor More... | |
void | setRandomSeed (unsigned long int new_seed) |
This is the seed for the random number generator. (note the call to seed_LFG is only required really if using that type of generator, but the other one is always required. More... | |
Mdouble | getRandomNumber (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 | setLinearCongruentialGeneratorParmeters (unsigned const int a, unsigned const int c, unsigned const int 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 | setLaggedFibonacciGeneratorParameters (const unsigned int p, const unsigned int q) |
This function sets the parameters for the LFG random number generator. More... | |
void | setRandomNumberGenerator (RNGType type) |
Allows the user to set which random number generator is used. More... | |
Private Member Functions | |
Mdouble | getRandomNumberFromLinearCongruentialGenerator (Mdouble min, Mdouble max) |
This is a basic Linear Congruential Generator Random. More... | |
Mdouble | getRandomNumberFromLaggedFibonacciGenerator (Mdouble min, Mdouble max) |
This is a Lagged Fibonacci Generator. More... | |
void | seedLaggedFibonacciGenerator () |
This seed the LFG. More... | |
Private Attributes | |
unsigned long int | randomSeedLinearCongruentialGenerator_ |
This is the initial seed of the RNG. More... | |
std::vector< Mdouble > | randomSeedLaggedFibonacciGenerator_ |
This is the seeds required for the LFG. More... | |
unsigned long int | a_ |
This are the two parameters that control the LCG random generated. More... | |
unsigned long int | c_ |
unsigned long int | m_ |
unsigned long int | p_ |
This are the parameters that control the LFG random generator. More... | |
unsigned long int | q_ |
RNGType | 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.
RNG::RNG | ( | ) |
default constructor
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 33 of file RNG.cc.
References a_, c_, LAGGED_FIBONACCI_GENERATOR, m_, p_, q_, randomSeedLaggedFibonacciGenerator_, randomSeedLinearCongruentialGenerator_, seedLaggedFibonacciGenerator(), and type_.
This is a random generating routine can be used for initial positions.
Definition at line 69 of file RNG.cc.
References getRandomNumberFromLaggedFibonacciGenerator(), getRandomNumberFromLinearCongruentialGenerator(), LAGGED_FIBONACCI_GENERATOR, LINEAR_CONGRUENTIAL_GENERATOR, and type_.
Referenced by Chute::createBottom(), ChuteInsertionBoundary::generateParticle(), CubeInsertionBoundary::generateParticle(), HopperInsertionBoundary::generateParticle(), ChuteBottom::setupInitialConditions(), and test().
This is a Lagged 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 115 of file RNG.cc.
References p_, q_, and randomSeedLaggedFibonacciGenerator_.
Referenced by getRandomNumber().
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 83 of file RNG.cc.
References a_, c_, m_, and randomSeedLinearCongruentialGenerator_.
Referenced by getRandomNumber(), and seedLaggedFibonacciGenerator().
void RNG::randomise | ( | ) |
sets the random variables such that they differ for each run
Definition at line 59 of file RNG.cc.
References setRandomSeed().
Referenced by DPMBase::readNextArgument().
|
private |
This seed the LFG.
Definition at line 103 of file RNG.cc.
References getRandomNumberFromLinearCongruentialGenerator(), p_, and randomSeedLaggedFibonacciGenerator_.
Referenced by RNG(), setLaggedFibonacciGeneratorParameters(), and setRandomSeed().
void RNG::setLaggedFibonacciGeneratorParameters | ( | const unsigned int | p, |
const unsigned int | q | ||
) |
This function sets the parameters for the LFG random number generator.
Definition at line 188 of file RNG.cc.
References p_, q_, randomSeedLaggedFibonacciGenerator_, and seedLaggedFibonacciGenerator().
void RNG::setLinearCongruentialGeneratorParmeters | ( | unsigned const int | a, |
unsigned const int | c, | ||
unsigned const int | m | ||
) |
void RNG::setRandomNumberGenerator | ( | RNGType | type | ) |
void RNG::setRandomSeed | ( | unsigned long int | new_seed | ) |
This is the seed for the random number generator. (note the call to seed_LFG is only required really if using that type of generator, but the other one is always required.
Definition at line 46 of file RNG.cc.
References randomSeedLinearCongruentialGenerator_, and seedLaggedFibonacciGenerator().
Referenced by DPMBase::constructor(), and randomise().
Mdouble RNG::test | ( | ) |
This function tests the quality of random numbers, based on the chi-squared test.
It reports a probability 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 140 of file RNG.cc.
References mathsFunc::chi_squared_prob(), and getRandomNumber().
|
private |
This are the two parameters that control the LCG random generated.
Definition at line 126 of file RNG.h.
Referenced by getRandomNumberFromLinearCongruentialGenerator(), RNG(), and setLinearCongruentialGeneratorParmeters().
|
private |
Definition at line 126 of file RNG.h.
Referenced by getRandomNumberFromLinearCongruentialGenerator(), RNG(), and setLinearCongruentialGeneratorParmeters().
|
private |
Definition at line 126 of file RNG.h.
Referenced by getRandomNumberFromLinearCongruentialGenerator(), RNG(), and setLinearCongruentialGeneratorParmeters().
|
private |
This are the parameters that control the LFG random generator.
Definition at line 131 of file RNG.h.
Referenced by getRandomNumberFromLaggedFibonacciGenerator(), RNG(), seedLaggedFibonacciGenerator(), and setLaggedFibonacciGeneratorParameters().
|
private |
Definition at line 131 of file RNG.h.
Referenced by getRandomNumberFromLaggedFibonacciGenerator(), RNG(), and setLaggedFibonacciGeneratorParameters().
|
private |
This is the seeds required for the LFG.
Definition at line 121 of file RNG.h.
Referenced by getRandomNumberFromLaggedFibonacciGenerator(), RNG(), seedLaggedFibonacciGenerator(), and setLaggedFibonacciGeneratorParameters().
|
private |
This is the initial seed of the RNG.
Definition at line 116 of file RNG.h.
Referenced by getRandomNumberFromLinearCongruentialGenerator(), RNG(), and setRandomSeed().
|
private |
This is the type of random number generator.
Definition at line 136 of file RNG.h.
Referenced by getRandomNumber(), RNG(), and setRandomNumberGenerator().