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>
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. | |
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(). | |
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. | |
void | quaternion (double value[4]) |
Uniform random unit quaternion sampling. The returned value has the order (x,y,z,w). | |
RNG (void) | |
Constructor. Always sets a different random seed. | |
double | uniform01 (void) |
Generate a random real between 0 and 1. | |
bool | uniformBool (void) |
Generate a random boolean. | |
int | uniformInt (int lower_bound, int upper_bound) |
Generate a random integer within given bounds: [lower_bound, upper_bound]. | |
double | uniformReal (double lower_bound, double upper_bound) |
Generate a random real within given bounds: [lower_bound, upper_bound). | |
Static Public Member Functions | |
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. | |
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. | |
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. 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.
ompl::RNG::RNG | ( | void | ) |
Constructor. Always sets a different random seed.
double ompl::RNG::gaussian | ( | double | mean, | |
double | stddev | |||
) | [inline] |
Generate a random real using a normal distribution with given mean and variance.
Definition at line 94 of file RandomNumbers.h.
double ompl::RNG::gaussian01 | ( | void | ) | [inline] |
Generate a random real using a normal distribution with mean 0 and variance 1.
Definition at line 88 of file RandomNumbers.h.
static boost::uint32_t ompl::RNG::getSeed | ( | void | ) | [static] |
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.
int ompl::RNG::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().
double ompl::RNG::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.
void ompl::RNG::quaternion | ( | double | value[4] | ) |
Uniform random unit quaternion sampling. The returned value has the order (x,y,z,w).
static void ompl::RNG::setSeed | ( | boost::uint32_t | seed | ) | [static] |
Set the seed for random number generation. Use this function to ensure the same sequence of random numbers is generated.
double ompl::RNG::uniform01 | ( | void | ) | [inline] |
Generate a random real between 0 and 1.
Definition at line 62 of file RandomNumbers.h.
bool ompl::RNG::uniformBool | ( | void | ) | [inline] |
Generate a random boolean.
Definition at line 82 of file RandomNumbers.h.
int ompl::RNG::uniformInt | ( | int | lower_bound, | |
int | upper_bound | |||
) | [inline] |
Generate a random integer within given bounds: [lower_bound, upper_bound].
Definition at line 75 of file RandomNumbers.h.
double ompl::RNG::uniformReal | ( | double | lower_bound, | |
double | upper_bound | |||
) | [inline] |
Generate a random real within given bounds: [lower_bound, upper_bound).
Definition at line 68 of file RandomNumbers.h.
boost::mt19937 ompl::RNG::generator_ [private] |
Definition at line 127 of file RandomNumbers.h.
boost::variate_generator<boost::mt19937&, boost::normal_distribution<> > ompl::RNG::normal_ [private] |
Definition at line 131 of file RandomNumbers.h.
boost::normal_distribution ompl::RNG::normalDist_ [private] |
Definition at line 129 of file RandomNumbers.h.
boost::variate_generator<boost::mt19937&, boost::uniform_real<> > ompl::RNG::uni_ [private] |
Definition at line 130 of file RandomNumbers.h.
boost::uniform_real ompl::RNG::uniDist_ [private] |
Definition at line 128 of file RandomNumbers.h.