Class RandomNumberGenerator

Class Documentation

class RandomNumberGenerator

Random number generation (wrapper for boost). An instance of this class cannot be used by multiple threads at once (member functions are not const). However, the constructor is thread safe and different instances can be used safely in any number of threads. It is also guaranteed that all created instances will have a “random” random seed.

Public Functions

RandomNumberGenerator(void)

Constructor. Always sets a “random” random seed.

RandomNumberGenerator(boost::uint32_t seed)

Constructor. Allow a seed to be specified for deterministic behaviour.

inline double uniform01(void)

Generate a random real between 0 and 1.

inline double uniformReal(double lower_bound, double upper_bound)

Generate a random real within given bounds: [lower_bound, upper_bound)

Parameters:
  • lower_bound – The lower bound

  • upper_bound – The upper bound

inline double gaussian01(void)

Generate a random real using a normal distribution with mean 0 and variance 1.

inline double gaussian(double mean, double stddev)

Generate a random real using a normal distribution with given mean and variance.

void quaternion(double value[4])

Uniform random unit quaternion sampling. The computed value has the order (x,y,z,w)

Parameters:

value[4] – A four dimensional array in which the computed quaternion will be returned

inline int uniformInteger(int min, int max)

Generate an integer uniformly at random within a specified range (inclusive)

boost::uint32_t getFirstSeed()

Allow the randomly generated seed to be saved so that experiments / benchmarks can be recreated in the future.