34 #ifndef __ENKI_RANDOM_H 35 #define __ENKI_RANDOM_H 57 void setSeed(
unsigned long seed) { randx = seed; }
59 unsigned long get(void) {
return (randx = randx*1103515245 + 12345) & 0x7fffffff; }
61 double getRange(
double range) {
return (static_cast<double>(
get()) * range) / 2147483648.0; }
68 return double(rand())/RAND_MAX;
78 UniformRand(
double from = 0.0,
double to = 1.0) { this->from = from; this->to = to; }
119 while (r > 1.0 || r == 0);
122 return sigm * y * sqrt (-2.0 * log(r) / r) + mean;
FastRandom(void)
Construct the random generator, initialize with a seed of 0.
Definition: Random.h:55
A fast random generator.
Definition: Random.h:48
Enki is the namespace of the Enki simulator. All Enki functions and classes excepted the math one are...
Definition: BluetoothBase.cpp:44
unsigned long randx
value used to compute next pseudo-random value
Definition: Random.h:51
void setSeed(unsigned long seed)
Set the seed.
Definition: Random.h:57
double gaussianRand(double mean, double sigm)
Return a random number with a gaussian distribution of a certain mean and standard deviation...
Definition: Random.h:103
bool boolRand(double prob=0.5)
Return true with a probability prob. If no argument is given, prob = 0.5.
Definition: Random.h:96
unsigned intRand(unsigned max)
Return a number between [0;max[ in integer in a uniform distribution.
Definition: Random.h:86
double getRange(double range)
Get a random double between 0 and range, use get() internally.
Definition: Random.h:61
double uniformRand(void)
Return a number in [0;1[ in a uniform distribution.
Definition: Random.h:66