23 #ifndef SPOT_MISC_RANDOM_HH
24 # define SPOT_MISC_RANDOM_HH
38 SPOT_API
void srand(
unsigned int seed);
44 SPOT_API
int rrand(
int min,
int max);
50 SPOT_API
int mrand(
int max);
56 SPOT_API
double drand();
64 SPOT_API
double nrand();
84 template<
double (*gen)()>
89 : n_(n), m_(n * p), s_(sqrt(n * p * (1 - p)))
100 double x = gen() * s_ + m_;
103 res =
static_cast<int> (x);
119 SPOT_API
int prand(
double p);
123 #endif // SPOT_MISC_RANDOM_HH
SPOT_API int prand(double p)
Return a pseudo-random positive integer value following a Poisson distribution with parameter p...
SPOT_API double nrand()
Compute a pseudo-random double value following a standard normal distribution. (Odeh & Evans) ...
SPOT_API double bmrand()
Compute a pseudo-random double value following a standard normal distribution. (Box-Muller) ...
SPOT_API int mrand(int max)
Compute a pseudo-random integer value between 0 and max-1 included.
SPOT_API int rrand(int min, int max)
Compute a pseudo-random integer value between min and max included.
SPOT_API double drand()
Compute a pseudo-random double value between 0.0 and 1.0 (1.0 excluded).
SPOT_API void srand(unsigned int seed)
Reset the seed of the pseudo-random number generator.
Compute pseudo-random integer value between 0 and n included, following a binomial distribution for p...
Definition: random.hh:85