20#ifndef RANDOMGENERATOR_H
21#define RANDOMGENERATOR_H
26#define RANDOMGENERATORSIZE 500000
27#define RANDOMGENERATORROTATIONS 0
36 static void debugState(
int &rIndex,
int &rGeneration,
int &rRefillCount) { rIndex = mIndex; rGeneration = mRotationCount; rRefillCount = mRefillCounter; }
43 static void seed(
const unsigned oneSeed);
45 static inline double rand() {
return next() * (1.0/4294967295.0); }
46 static inline double rand(
const double max_value) {
return max_value *
rand(); }
48 static inline unsigned long randInt(){
return next(); }
49 static inline unsigned long randInt(
const int max_value) {
return max_value>0?
randInt()%max_value:0; }
51 static inline double randNorm(
const double mean,
const double stddev );
57 static int mRotationCount;
58 static int mRefillCounter;
69inline double nrandom(
const double& p1,
const double& p2)
97 x = 2.0 *
rand() - 1.0;
98 y = 2.0 *
rand() - 1.0;
101 while ( r >= 1.0 || r == 0.0 );
102 double s = sqrt( -2.0 * log(r) / r );
103 return mean + x * s * stddev;
Definition: randomgenerator.h:30
static unsigned long randInt()
get a random integer in [0,2^32-1]
Definition: randomgenerator.h:48
static void seed(const unsigned oneSeed)
set a random generator seed. If oneSeed is 0, then a random number (provided by system time) is used ...
Definition: randomgenerator.cpp:167
static double rand(const double max_value)
Definition: randomgenerator.h:46
static void setup(const ERandomGenerators gen, const unsigned oneSeed)
Definition: randomgenerator.h:41
static void debugState(int &rIndex, int &rGeneration, int &rRefillCount)
Definition: randomgenerator.h:36
static double rand()
get a random value from [0., 1.]
Definition: randomgenerator.h:45
static void checkGenerator()
call this function to check if we need to create new random numbers.
Definition: randomgenerator.h:40
static int debugNRandomNumbers()
Definition: randomgenerator.h:37
static void setGeneratorType(const ERandomGenerators gen)
set the type of the random generator that should be used.
Definition: randomgenerator.h:35
ERandomGenerators
Definition: randomgenerator.h:32
@ ergFastRandom
Definition: randomgenerator.h:32
@ ergMersenneTwister
Definition: randomgenerator.h:32
@ ergWellRNG512
Definition: randomgenerator.h:32
@ ergXORShift96
Definition: randomgenerator.h:32
static double randNorm(const double mean, const double stddev)
Access to nonuniform random number distributions.
Definition: randomgenerator.h:90
static unsigned long randInt(const int max_value)
Definition: randomgenerator.h:49
RandomGenerator()
Definition: randomgenerator.h:33
double drandom()
returns a random number in [0,1] (i.e.="1" is a possible result!)
Definition: randomgenerator.h:75
#define RANDOMGENERATORROTATIONS
Definition: randomgenerator.h:27
int irandom(int from, int to)
return a random number from "from" to "to" (excluding 'to'.), i.e. irandom(3,6) results in 3,...
Definition: randomgenerator.h:81
double nrandom(const double &p1, const double &p2)
nrandom returns a random number from [p1, p2] -> p2 is a possible result!
Definition: randomgenerator.h:69
#define RANDOMGENERATORSIZE
Definition: randomgenerator.h:26