1 /*
2    Simple Random Number Generators
3        - getuniform - uniform deviate [0,1]
4        - getnorm    - gaussian (normal) deviate (mean=0, stddev=1)
5        - getpoisson - poisson deviate for given expected mean lambda
6 
7    This code is adapted from SimpleRNG by John D Cook, which is
8    provided in the public domain.
9 
10    The original C++ code is found here:
11    http://www.johndcook.com/cpp_random_number_generation.html
12 
13    This code has been modified in the following ways compared to the
14    original.
15      1. convert to C from C++
16      2. keep only uniform, gaussian and poisson deviates
17      3. state variables are module static instead of class variables
18      4. provide an srand() equivalent to initialize the state
19 */
20 
21 extern void simplerng_setstate(unsigned int u, unsigned int v);
22 extern void simplerng_getstate(unsigned int *u, unsigned int *v);
23 extern void simplerng_srand(unsigned int seed);
24 extern double simplerng_getuniform(void);
25 extern double simplerng_getnorm(void);
26 extern int simplerng_getpoisson(double lambda);
27 extern double simplerng_logfactorial(int n);
28