All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator

Random number generation. 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 different random seed. More...

#include <RandomNumbers.h>

List of all members.

Public Member Functions

 RNG (void)
 Constructor. Always sets a different random seed.
double uniform01 (void)
 Generate a random real between 0 and 1.
double uniformReal (double lower_bound, double upper_bound)
 Generate a random real within given bounds: [lower_bound, upper_bound)
int uniformInt (int lower_bound, int upper_bound)
 Generate a random integer within given bounds: [lower_bound, upper_bound].
bool uniformBool (void)
 Generate a random boolean.
double gaussian01 (void)
 Generate a random real using a normal distribution with mean 0 and variance 1.
double gaussian (double mean, double stddev)
 Generate a random real using a normal distribution with given mean and variance.
double halfNormalReal (double r_min, double r_max, double focus=3.0)
 Generate a random real using a half-normal distribution. The value is within specified bounds [r_min, r_max], but with a bias towards r_max. The function is implemended using a Gaussian distribution with mean at r_max - r_min. The distribution is 'folded' around r_max axis towards r_min. The variance of the distribution is (r_max - r_min) / focus. The higher the focus, the more probable it is that generated numbers are close to r_max.
int halfNormalInt (int r_min, int r_max, double focus=3.0)
 Generate a random integer using a half-normal distribution. The value is within specified bounds ([r_min, r_max]), but with a bias towards r_max. The function is implemented on top of halfNormalReal()
void quaternion (double value[4])
 Uniform random unit quaternion sampling. The returned value has the order (x,y,z,w)

Static Public Member Functions

static void setSeed (boost::uint32_t seed)
 Set the seed for random number generation. Use this function to ensure the same sequence of random numbers is generated.
static boost::uint32_t getSeed (void)
 Get the seed used for random number generation. Passing the returned value to setSeed() at a subsequent execution of the code will ensure deterministic (repeatable) behaviour. Useful for debugging.

Detailed Description

Random number generation. 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 different random seed.

Definition at line 54 of file RandomNumbers.h.


The documentation for this class was generated from the following files: