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. More...
#include <random_numbers.h>
Public Member Functions | |
double | gaussian (double mean, double stddev) |
Generate a random real using a normal distribution with given mean and variance. | |
double | gaussian01 (void) |
Generate a random real using a normal distribution with mean 0 and variance 1. | |
boost::uint32_t | getFirstSeed () |
Allow the randomly generated seed to be saved so that experiments / benchmarks can be recreated in the future. | |
void | quaternion (double value[4]) |
Uniform random unit quaternion sampling. The computed value has the order (x,y,z,w) | |
RandomNumberGenerator (void) | |
Constructor. Always sets a "random" random seed. | |
RandomNumberGenerator (boost::uint32_t seed) | |
Constructor. Allow a seed to be specified for deterministic behaviour. | |
double | uniform01 (void) |
Generate a random real between 0 and 1. | |
int | uniformInteger (int min, int max) |
Generate an integer uniformly at random within a specified range (inclusive) | |
double | uniformReal (double lower_bound, double upper_bound) |
Generate a random real within given bounds: [lower_bound, upper_bound) | |
Private Attributes | |
boost::mt19937 | generator_ |
boost::variate_generator < boost::mt19937 &, boost::normal_distribution<> > | normal_ |
boost::normal_distribution | normalDist_ |
boost::variate_generator < boost::mt19937 &, boost::uniform_real<> > | uni_ |
boost::uniform_real | uniDist_ |
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.
Definition at line 54 of file random_numbers.h.
Constructor. Always sets a "random" random seed.
Definition at line 73 of file random_numbers.cpp.
random_numbers::RandomNumberGenerator::RandomNumberGenerator | ( | boost::uint32_t | seed | ) |
Constructor. Allow a seed to be specified for deterministic behaviour.
Definition at line 82 of file random_numbers.cpp.
double random_numbers::RandomNumberGenerator::gaussian | ( | double | mean, |
double | stddev | ||
) | [inline] |
Generate a random real using a normal distribution with given mean and variance.
Definition at line 86 of file random_numbers.h.
double random_numbers::RandomNumberGenerator::gaussian01 | ( | void | ) | [inline] |
Generate a random real using a normal distribution with mean 0 and variance 1.
Definition at line 80 of file random_numbers.h.
boost::uint32_t random_numbers::RandomNumberGenerator::getFirstSeed | ( | ) |
Allow the randomly generated seed to be saved so that experiments / benchmarks can be recreated in the future.
Definition at line 105 of file random_numbers.cpp.
void random_numbers::RandomNumberGenerator::quaternion | ( | double | value[4] | ) |
Uniform random unit quaternion sampling. The computed value has the order (x,y,z,w)
value[4] | A four dimensional array in which the computed quaternion will be returned |
Definition at line 91 of file random_numbers.cpp.
double random_numbers::RandomNumberGenerator::uniform01 | ( | void | ) | [inline] |
Generate a random real between 0 and 1.
Definition at line 64 of file random_numbers.h.
int random_numbers::RandomNumberGenerator::uniformInteger | ( | int | min, |
int | max | ||
) | [inline] |
Generate an integer uniformly at random within a specified range (inclusive)
Definition at line 97 of file random_numbers.h.
double random_numbers::RandomNumberGenerator::uniformReal | ( | double | lower_bound, |
double | upper_bound | ||
) | [inline] |
Generate a random real within given bounds: [lower_bound, upper_bound)
lower_bound | The lower bound |
upper_bound | The upper bound |
Definition at line 74 of file random_numbers.h.
boost::mt19937 random_numbers::RandomNumberGenerator::generator_ [private] |
Definition at line 110 of file random_numbers.h.
boost::variate_generator<boost::mt19937&, boost::normal_distribution<> > random_numbers::RandomNumberGenerator::normal_ [private] |
Definition at line 114 of file random_numbers.h.
boost::normal_distribution random_numbers::RandomNumberGenerator::normalDist_ [private] |
Definition at line 112 of file random_numbers.h.
boost::variate_generator<boost::mt19937&, boost::uniform_real<> > random_numbers::RandomNumberGenerator::uni_ [private] |
Definition at line 113 of file random_numbers.h.
boost::uniform_real random_numbers::RandomNumberGenerator::uniDist_ [private] |
Definition at line 111 of file random_numbers.h.