/******************************************/ /* random.h 0.0.0 (1999-Oct-13-Wed) */ /* Adam M. Costello */ /******************************************/ /* Generate pseudo-random numbers with various distributions. */ /* This is ANSI C code. */ #ifndef RANDOM_H #define RANDOM_H double random_uniform(double x0, int include0, double x1, int include1); /* Returns a random number chosen uniformly between x0 and x1 */ /* (either may be larger). Each endpoint is included iff the */ /* corresponding flag is non-zero. If only one endpoint is */ /* excluded, it will not be returned unless the endpoints are */ /* equal. If both endpoints are excluded, neither will be */ /* returned unless there are no representable numbers between */ /* them. */ double random_uniform01(void); /* Returns a random number chosen uniformly */ /* between 0.0 and 1.0 inclusive. This is */ /* equivalent to random_uniform(0.0, 1, 1.0, 1). */ long random_discrete_uniform(long n0, long n1); /* Returns a random long integer chosen uniformly */ /* between n0 and n1 inclusive (either may be larger). */ int random_bernoulli(double p); /* Returns 1 with probability p, 0 otherwise. */ int random_bit(void); /* Returns 0 or 1, with an equal probability of */ /* each. This is equivalent to random_bernoulli(0.5). */ double random_exponential(double mean); /* Returns a non-negative number (possibly zero) with */ /* an exponential distribution with the given mean. */ double random_rayleigh(double mean); /* Returns a non-negative number (possibly zero) with a */ /* Rayleigh distribution with the given mean. If the x */ /* and y coordinates of a point have independent normal */ /* distributions with standard deviation sigma, then its */ /* distance from the origin has a Rayleigh distribution */ /* with mean sqrt(PI/2)*sigma. */ #endif /* RANDOM_H */