MercuryDPM  Trunk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RNG Class Reference

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...
 
void read (std::istream &is)
 
void write (std::ostream &os) const
 
Mdouble getRandomNumber ()
 This is a random generating routine can be used for initial positions. More...
 
Mdouble getRandomNumber (Mdouble min, Mdouble max)
 
Mdouble operator() (Mdouble min, Mdouble max)
 Shorthand for getRandomNumber(min, max) More...
 
Mdouble operator() ()
 
Mdouble getNormalVariate ()
 Produces a random number according to a normal distribution with mean 0 and standard deviation 1. More...
 
Mdouble getNormalVariate (Mdouble mean, Mdouble stdev)
 Produces a random number according to a normal distribution. More...
 
unsigned int getPoissonVariate (Mdouble lambda)
 Produces a random number according to a Poisson distribution. More...
 
Mdouble test ()
 This function tests the quality of random numbers, based on the chi-squared test. More...
 
void setLinearCongruentialGeneratorParmeters (const unsigned int a, const unsigned int c, unsigned 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< MdoublerandomSeedLaggedFibonacciGenerator_
 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...
 
bool haveSavedBoxMuller_
 A flag that keeps track of whether or not to generate a new pair of normal variates (using Box–Muller) More...
 
Mdouble savedBoxMuller_
 A storage space for the so-far-unused variate from the pair generated by Box–Muller. More...
 

Detailed Description

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.

Todo:
(AT) implement new C++-standard RNG instead of this one (Kudos on the hard work done here though ;). NB: maybe something for Mercury 2?

Definition at line 52 of file RNG.h.

Constructor & Destructor Documentation

RNG::RNG ( )

default constructor

This is a random number generator and returns a Mdouble within the range specified.

Todo:

{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 36 of file RNG.cc.

References a_, c_, haveSavedBoxMuller_, LAGGED_FIBONACCI_GENERATOR, m_, p_, q_, randomSeedLaggedFibonacciGenerator_, randomSeedLinearCongruentialGenerator_, savedBoxMuller_, seedLaggedFibonacciGenerator(), and type_.

37 {
39  a_ = 1103515245;
40  c_ = 12345;
41  m_ = 1024 * 1024 * 1024;
43  p_ = 607;
44  q_ = 273;
47 
48  haveSavedBoxMuller_ = false;
49  savedBoxMuller_ = 0;
50 
51 }
unsigned long int c_
Definition: RNG.h:164
void seedLaggedFibonacciGenerator()
This seed the LFG.
Definition: RNG.cc:254
unsigned long int q_
Definition: RNG.h:169
Mdouble savedBoxMuller_
A storage space for the so-far-unused variate from the pair generated by Box–Muller.
Definition: RNG.h:190
unsigned long int randomSeedLinearCongruentialGenerator_
This is the initial seed of the RNG.
Definition: RNG.h:154
unsigned long int p_
This are the parameters that control the LFG random generator.
Definition: RNG.h:169
bool haveSavedBoxMuller_
A flag that keeps track of whether or not to generate a new pair of normal variates (using Box–Mulle...
Definition: RNG.h:185
std::vector< Mdouble > randomSeedLaggedFibonacciGenerator_
This is the seeds required for the LFG.
Definition: RNG.h:159
unsigned long int a_
This are the two parameters that control the LCG random generated.
Definition: RNG.h:164
RNGType type_
This is the type of random number generator.
Definition: RNG.h:174
unsigned long int m_
Definition: RNG.h:164

Member Function Documentation

Mdouble RNG::getNormalVariate ( )

Produces a random number according to a normal distribution with mean 0 and standard deviation 1.

Definition at line 164 of file RNG.cc.

References mathsFunc::cos(), getRandomNumber(), haveSavedBoxMuller_, mathsFunc::log(), constants::pi, savedBoxMuller_, and mathsFunc::sin().

Referenced by getNormalVariate().

165 {
166  static const double epsilon = std::numeric_limits<Mdouble>::min();
167 
169  {
170  /* If we have already generated a normal variate, use it. */
171  haveSavedBoxMuller_ = false;
172  return savedBoxMuller_;
173  }
174  else
175  {
176  /* Otherwise, generate a pair of normal variates, return one of them,
177  * and save the other. */
178  Mdouble radius, theta;
179  do
180  {
181  radius = getRandomNumber(0, 1);
182  theta = getRandomNumber(0, 2 * constants::pi);
183  } while (radius <= epsilon);
184  // make sure that the radius generated is not too small
185  // (unlikely to happen, just a safety check)
186 
187  savedBoxMuller_ = sqrt(-2.0 * log(radius)) * sin(theta);
188  haveSavedBoxMuller_ = true;
189  return sqrt(-2.0 * log(radius)) * cos(theta);
190  }
191 }
double Mdouble
Definition: GeneralDefine.h:34
Mdouble getRandomNumber()
This is a random generating routine can be used for initial positions.
Definition: RNG.cc:143
Mdouble log(Mdouble Power)
Mdouble cos(Mdouble x)
Definition: ExtendedMath.cc:64
Mdouble sin(Mdouble x)
Definition: ExtendedMath.cc:44
const Mdouble pi
Definition: ExtendedMath.h:45
Mdouble savedBoxMuller_
A storage space for the so-far-unused variate from the pair generated by Box–Muller.
Definition: RNG.h:190
bool haveSavedBoxMuller_
A flag that keeps track of whether or not to generate a new pair of normal variates (using Box–Mulle...
Definition: RNG.h:185
Mdouble RNG::getNormalVariate ( Mdouble  mean,
Mdouble  stdev 
)

Produces a random number according to a normal distribution.

Definition at line 193 of file RNG.cc.

References ERROR, getNormalVariate(), logger, and WARN.

194 {
195  if (stdev == 0) {
196  logger(WARN,
197  "[RNG::getNormalVariate(Mdouble, Mdouble)] Zero stdev?");
198  return mean;
199  } else if (stdev < 0) {
200  logger(ERROR,
201  "[RNG::getNormalVariate(Mdouble, Mdouble)] Negative stdev is not allowed.");
202  } else {
203  return getNormalVariate() * stdev + mean;
204  }
205 }
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here...
Mdouble getNormalVariate()
Produces a random number according to a normal distribution with mean 0 and standard deviation 1...
Definition: RNG.cc:164
unsigned int RNG::getPoissonVariate ( Mdouble  lambda)

Produces a random number according to a Poisson distribution.

This uses Knuth's algorithm for generating Poisson variates. It's simple but slow for large values of lambda — beware.

Definition at line 211 of file RNG.cc.

References mathsFunc::exp(), getRandomNumber(), logger, and WARN.

Referenced by CurvyChute::createBottom().

212 {
213  if (lambda > 50)
214  {
215  logger(WARN, "[RNG::getPoissonVariate(Mdouble)] Knuth's algorithm for Poissons may be slow for lambda = %", lambda);
216  }
217  unsigned int k = 0;
218  Mdouble p = 1;
219  Mdouble u;
220  do
221  {
222  k++;
223  u = getRandomNumber(0, 1);
224  p *= u;
225  }
226  while (u > exp(-lambda));
227  return k-1;
228 }
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here...
double Mdouble
Definition: GeneralDefine.h:34
Mdouble exp(Mdouble Exponent)
Definition: ExtendedMath.cc:84
Mdouble getRandomNumber()
This is a random generating routine can be used for initial positions.
Definition: RNG.cc:143
Mdouble RNG::getRandomNumber ( Mdouble  min,
Mdouble  max 
)

Definition at line 148 of file RNG.cc.

References getRandomNumberFromLaggedFibonacciGenerator(), getRandomNumberFromLinearCongruentialGenerator(), LINEAR_CONGRUENTIAL_GENERATOR, logger, and type_.

149 {
150  logger.assert_debug(min <= max, "getRandomNumber: min cannot be larger than max");
153  } else {
155  }
156 }
Mdouble getRandomNumberFromLaggedFibonacciGenerator(Mdouble min, Mdouble max)
This is a Lagged Fibonacci Generator.
Definition: RNG.cc:266
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here...
Mdouble getRandomNumberFromLinearCongruentialGenerator(Mdouble min, Mdouble max)
This is a basic Linear Congruential Generator Random.
Definition: RNG.cc:235
RNGType type_
This is the type of random number generator.
Definition: RNG.h:174
Mdouble RNG::getRandomNumberFromLaggedFibonacciGenerator ( Mdouble  min,
Mdouble  max 
)
private

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 266 of file RNG.cc.

References p_, q_, and randomSeedLaggedFibonacciGenerator_.

Referenced by getRandomNumber().

267 {
268 #pragma optimize( "", off )
270  static_cast<Mdouble>(1.0));
271  //Update the random seed
273  randomSeedLaggedFibonacciGenerator_.emplace_back(new_seed);
274 
275  //Generate a random number in the required range
276 
277  Mdouble random_num;
278 
279  Mdouble range = max - min;
280  random_num = min + range * new_seed;
281  return random_num;
282 #pragma optimize( "", on )
283 }
double Mdouble
Definition: GeneralDefine.h:34
unsigned long int q_
Definition: RNG.h:169
unsigned long int p_
This are the parameters that control the LFG random generator.
Definition: RNG.h:169
std::vector< Mdouble > randomSeedLaggedFibonacciGenerator_
This is the seeds required for the LFG.
Definition: RNG.h:159
Mdouble RNG::getRandomNumberFromLinearCongruentialGenerator ( Mdouble  min,
Mdouble  max 
)
private

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 235 of file RNG.cc.

References a_, c_, m_, and randomSeedLinearCongruentialGenerator_.

Referenced by getRandomNumber(), and seedLaggedFibonacciGenerator().

236 {
237  //Update the random seed
239 
240  //Generate a random number in the required range
241 
242  Mdouble range = max - min;
243  Mdouble random_num = min + range * randomSeedLinearCongruentialGenerator_ / (static_cast<Mdouble>(m_) + 1.0);
244 
245  return random_num;
246 }
unsigned long int c_
Definition: RNG.h:164
double Mdouble
Definition: GeneralDefine.h:34
unsigned long int randomSeedLinearCongruentialGenerator_
This is the initial seed of the RNG.
Definition: RNG.h:154
unsigned long int a_
This are the two parameters that control the LCG random generated.
Definition: RNG.h:164
unsigned long int m_
Definition: RNG.h:164
Mdouble RNG::operator() ( Mdouble  min,
Mdouble  max 
)
inline

Shorthand for getRandomNumber(min, max)

Definition at line 80 of file RNG.h.

References getRandomNumber().

81  {
82  return getRandomNumber(min, max);
83  }
Mdouble getRandomNumber()
This is a random generating routine can be used for initial positions.
Definition: RNG.cc:143
Mdouble RNG::operator() ( )
inline

Definition at line 88 of file RNG.h.

References getRandomNumber().

89  {
90  return getRandomNumber(0.0, 1.0);
91  }
Mdouble getRandomNumber()
This is a random generating routine can be used for initial positions.
Definition: RNG.cc:143
void RNG::randomise ( )

sets the random variables such that they differ for each run

Definition at line 98 of file RNG.cc.

References a_, MPIContainer::broadcast(), c_, MPIContainer::Instance(), m_, p_, PROCESSOR_ID, q_, randomSeedLinearCongruentialGenerator_, seedLaggedFibonacciGenerator(), setRandomSeed(), and type_.

Referenced by FixedClusterInsertionBoundary::checkBoundaryBeforeTimeStep(), RandomClusterInsertionBoundary::checkBoundaryBeforeTimeStep(), FixedClusterInsertionBoundary::placeParticle(), RandomClusterInsertionBoundary::placeParticle(), and DPMBase::readNextArgument().

99 {
100 #ifdef MERCURY_USE_MPI
101  //First set a random seed on the root
102  if (PROCESSOR_ID == 0)
103  {
104  setRandomSeed(static_cast<unsigned long int>(time(nullptr)));
105  }
106 
107  //Communicate this to the rest of the processes
108  std::vector<int> values(7);
109  if (PROCESSOR_ID == 0)
110  {
111  values[0] = static_cast<unsigned int>(type_);
112  values[1] = a_;
113  values[2] = c_;
114  values[3] = m_;
115  values[4] = p_;
116  values[5] = q_;
118  }
119  MPIContainer::Instance().broadcast(values.data(),7,0);
120 
121  //Update the generators on the other processors
122  if (PROCESSOR_ID != 0)
123  {
124  type_ = static_cast<RNGType>(values[0]);
125  a_ = values[1];
126  c_ = values[2];
127  m_ = values[3];
128  p_ = values[4];
129  q_ = values[5];
131  }
133 #else
134  setRandomSeed(static_cast<unsigned long int>(time(nullptr)));
135 #endif
136 }
static MPIContainer & Instance()
fetch the instance to be used for communication
Definition: MpiContainer.h:134
unsigned long int c_
Definition: RNG.h:164
void seedLaggedFibonacciGenerator()
This seed the LFG.
Definition: RNG.cc:254
unsigned long int q_
Definition: RNG.h:169
#define PROCESSOR_ID
Definition: GeneralDefine.h:63
unsigned long int randomSeedLinearCongruentialGenerator_
This is the initial seed of the RNG.
Definition: RNG.h:154
unsigned long int p_
This are the parameters that control the LFG random generator.
Definition: RNG.h:169
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 i...
Definition: RNG.cc:53
std::enable_if< std::is_scalar< T >::value, void >::type broadcast(T &t, int fromProcessor=0)
Broadcasts a scalar from the root to all other processors.
Definition: MpiContainer.h:441
unsigned long int a_
This are the two parameters that control the LCG random generated.
Definition: RNG.h:164
RNGType
Definition: RNG.h:38
RNGType type_
This is the type of random number generator.
Definition: RNG.h:174
unsigned long int m_
Definition: RNG.h:164
void RNG::read ( std::istream &  is)

Definition at line 59 of file RNG.cc.

References a_, c_, m_, p_, q_, randomSeedLinearCongruentialGenerator_, seedLaggedFibonacciGenerator(), and type_.

Referenced by DPMBase::read().

60 {
61  std::string dummy;
62  unsigned int type;
63  is >> type;
64  type_ = static_cast<RNGType>(type);
65  is >> a_;
66  is >> c_;
67  is >> m_;
68  is >> p_;
69  is >> q_;
71  //note: the seeds for the LaggedFibonacciGenerator cannot be restarted currently.
73  //randomSeedLaggedFibonacciGenerator_.resize(p_);
74  //for (auto& v : randomSeedLaggedFibonacciGenerator_)
75  // is >> v;
76 }
unsigned long int c_
Definition: RNG.h:164
void seedLaggedFibonacciGenerator()
This seed the LFG.
Definition: RNG.cc:254
unsigned long int q_
Definition: RNG.h:169
unsigned long int randomSeedLinearCongruentialGenerator_
This is the initial seed of the RNG.
Definition: RNG.h:154
unsigned long int p_
This are the parameters that control the LFG random generator.
Definition: RNG.h:169
unsigned long int a_
This are the two parameters that control the LCG random generated.
Definition: RNG.h:164
RNGType
Definition: RNG.h:38
RNGType type_
This is the type of random number generator.
Definition: RNG.h:174
unsigned long int m_
Definition: RNG.h:164
void RNG::seedLaggedFibonacciGenerator ( )
private

This seed the LFG.

Definition at line 254 of file RNG.cc.

References getRandomNumberFromLinearCongruentialGenerator(), constants::i, p_, and randomSeedLaggedFibonacciGenerator_.

Referenced by randomise(), read(), RNG(), setLaggedFibonacciGeneratorParameters(), and setRandomSeed().

255 {
256  for (unsigned int i = 0; i < p_; i++)
257  {
259  }
260 }
const std::complex< Mdouble > i
Definition: ExtendedMath.h:51
Mdouble getRandomNumberFromLinearCongruentialGenerator(Mdouble min, Mdouble max)
This is a basic Linear Congruential Generator Random.
Definition: RNG.cc:235
unsigned long int p_
This are the parameters that control the LFG random generator.
Definition: RNG.h:169
std::vector< Mdouble > randomSeedLaggedFibonacciGenerator_
This is the seeds required for the LFG.
Definition: RNG.h:159
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 339 of file RNG.cc.

References p_, q_, randomSeedLaggedFibonacciGenerator_, and seedLaggedFibonacciGenerator().

340 {
341  //p must be greater than q so makes sure this is true. Not sure what happens if you set p=q, in the LFG alogrithm.
342  if (p < q)
343  {
344  p_ = q;
345  q_ = p;
346  }
347 
350 }
void seedLaggedFibonacciGenerator()
This seed the LFG.
Definition: RNG.cc:254
unsigned long int q_
Definition: RNG.h:169
unsigned long int p_
This are the parameters that control the LFG random generator.
Definition: RNG.h:169
std::vector< Mdouble > randomSeedLaggedFibonacciGenerator_
This is the seeds required for the LFG.
Definition: RNG.h:159
void RNG::setLinearCongruentialGeneratorParmeters ( const unsigned int  a,
const unsigned int  c,
unsigned int  m 
)

This functions set the parameters for the LCG random number generator. It goes multiplier, addition, mod.

Definition at line 91 of file RNG.cc.

References a_, c_, and m_.

92 {
93  a_ = a;
94  c_ = c;
95  m_ = m;
96 }
unsigned long int c_
Definition: RNG.h:164
unsigned long int a_
This are the two parameters that control the LCG random generated.
Definition: RNG.h:164
unsigned long int m_
Definition: RNG.h:164
void RNG::setRandomNumberGenerator ( RNGType  type)

Allows the user to set which random number generator is used.

Definition at line 138 of file RNG.cc.

References type_.

139 {
140  type_ = type;
141 }
RNGType type_
This is the type of random number generator.
Definition: RNG.h:174
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 53 of file RNG.cc.

References randomSeedLinearCongruentialGenerator_, and seedLaggedFibonacciGenerator().

Referenced by DPMBase::constructor(), and randomise().

54 {
57 }
void seedLaggedFibonacciGenerator()
This seed the LFG.
Definition: RNG.cc:254
unsigned long int randomSeedLinearCongruentialGenerator_
This is the initial seed of the RNG.
Definition: RNG.h:154
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 290 of file RNG.cc.

References mathsFunc::chi_squared_prob(), getRandomNumber(), constants::i, INFO, logger, and NO_FLUSH.

291 {
292  //This are the fixed parameters that define the test
293  static unsigned int num_of_tests = 100000;
294  static Mdouble max_num = 100.0;
295  static unsigned int num_of_bins = 10;
296 
297  //This is the generated random_number
298  Mdouble rn;
299  //This is the bin the random number will lie in
300  unsigned int bin = 0;
301  //This is a vector of bins
302  std::vector<int> count;
303  count.resize(num_of_bins);
304 
305  //Initialisation of the bins
306  for (unsigned int i = 0; i < num_of_bins; i++)
307  {
308  count[bin] = 0;
309  }
310 
311  //Loop over a number of tests
312  for (unsigned int i = 0; i < num_of_tests; i++)
313  {
314  rn = getRandomNumber(0.0, max_num);
315  bin = static_cast<unsigned int>(std::floor(rn * num_of_bins / max_num));
316 
317  //Add one to the bin count
318  count[bin]++;
319 
320  }
321 
322  //Final post-process the result and report on the random number
323  Mdouble chi_cum = 0.0;
324  Mdouble expected = num_of_tests / num_of_bins;
325 
326  for (unsigned int i = 0; i < num_of_bins; i++)
327  {
328  chi_cum = chi_cum + (count[i] - expected) * (count[i] - expected) / expected;
329  logger(INFO, "% : % : %\n", Flusher::NO_FLUSH, i, count[i], (count[i] - expected) * (count[i] - expected) /
330  expected);
331  }
332  //end for loop over computing the chi-squared value.
333  logger(INFO, "chi_cum %", chi_cum);
334 
335  return mathsFunc::chi_squared_prob(chi_cum, num_of_bins);
336 }
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here...
double Mdouble
Definition: GeneralDefine.h:34
const std::complex< Mdouble > i
Definition: ExtendedMath.h:51
Mdouble getRandomNumber()
This is a random generating routine can be used for initial positions.
Definition: RNG.cc:143
Mdouble chi_squared_prob(Mdouble x, unsigned int k)
This is the function which actually gives the probability back using a chi squared test...
void RNG::write ( std::ostream &  os) const

Definition at line 78 of file RNG.cc.

References a_, c_, m_, p_, q_, randomSeedLinearCongruentialGenerator_, and type_.

Referenced by DPMBase::write().

79 {
80  os << " " << static_cast<unsigned int>(type_);
81  os << " " << a_;
82  os << " " << c_;
83  os << " " << m_;
84  os << " " << p_;
85  os << " " << q_;
87  //for (auto v : randomSeedLaggedFibonacciGenerator_)
88  // os << " " << v;
89 }
unsigned long int c_
Definition: RNG.h:164
unsigned long int q_
Definition: RNG.h:169
unsigned long int randomSeedLinearCongruentialGenerator_
This is the initial seed of the RNG.
Definition: RNG.h:154
unsigned long int p_
This are the parameters that control the LFG random generator.
Definition: RNG.h:169
unsigned long int a_
This are the two parameters that control the LCG random generated.
Definition: RNG.h:164
RNGType type_
This is the type of random number generator.
Definition: RNG.h:174
unsigned long int m_
Definition: RNG.h:164

Member Data Documentation

unsigned long int RNG::a_
private

This are the two parameters that control the LCG random generated.

Definition at line 164 of file RNG.h.

Referenced by getRandomNumberFromLinearCongruentialGenerator(), randomise(), read(), RNG(), setLinearCongruentialGeneratorParmeters(), and write().

bool RNG::haveSavedBoxMuller_
private

A flag that keeps track of whether or not to generate a new pair of normal variates (using Box–Muller)

Definition at line 185 of file RNG.h.

Referenced by getNormalVariate(), and RNG().

unsigned long int RNG::p_
private

This are the parameters that control the LFG random generator.

Definition at line 169 of file RNG.h.

Referenced by getRandomNumberFromLaggedFibonacciGenerator(), randomise(), read(), RNG(), seedLaggedFibonacciGenerator(), setLaggedFibonacciGeneratorParameters(), and write().

unsigned long int RNG::q_
private
std::vector<Mdouble> RNG::randomSeedLaggedFibonacciGenerator_
private

This is the seeds required for the LFG.

Definition at line 159 of file RNG.h.

Referenced by getRandomNumberFromLaggedFibonacciGenerator(), RNG(), seedLaggedFibonacciGenerator(), and setLaggedFibonacciGeneratorParameters().

unsigned long int RNG::randomSeedLinearCongruentialGenerator_
private

This is the initial seed of the RNG.

Definition at line 154 of file RNG.h.

Referenced by getRandomNumberFromLinearCongruentialGenerator(), randomise(), read(), RNG(), setRandomSeed(), and write().

Mdouble RNG::savedBoxMuller_
private

A storage space for the so-far-unused variate from the pair generated by Box–Muller.

Definition at line 190 of file RNG.h.

Referenced by getNormalVariate(), and RNG().

RNGType RNG::type_
private

This is the type of random number generator.

Definition at line 174 of file RNG.h.

Referenced by getRandomNumber(), randomise(), read(), RNG(), setRandomNumberGenerator(), and write().


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