25.1.3.1 Member Functions

The random number generator is implemented by the RNG class and is defined in tools/rng.h.

Note: The Random class in tools/random.h is an older interface to the standard random number stream.

Member functions provide the following operations:

void set_seed (long seed)
- set the seed of the RNG, if $seed == 0$, the seed is set according to the current time and a counter
long seed (void)
- return the current seed
long next (void)
- return the next random number as an integer on [0, MAXINT]
double next_double (void)
- return the next random number on [0, 1]
void reset_start_substream (void)
- reset the stream to the beginning of the current substream
void reset_next_substream (void)
- advance to the next substream
int uniform (int k)
- return an integer sampled from a uniform distribution on [0, k-1]
double uniform (double r)
- return a number sampled from a uniform distribution on [0, r]
double uniform (double a, double b)
- return a number sampled from a uniform distribution on [a, b]
double exponential (void)
- return a number sampled from an exponential distribution with mean 1.0
double exponential (double k)
- return a number sampled from an exponential distribution with mean k
double normal (double avg, double std)
- return a number sampled from a normal distribution with the given average and standard deviation
double lognormal (double avg, double std)
- return a number sampled from a lognormal distribution with the given average and standard deviation

Tom Henderson 2011-11-05