37 #ifndef OMPL_UTIL_RANDOM_NUMBERS_
38 #define OMPL_UTIL_RANDOM_NUMBERS_
40 #include <boost/random/mersenne_twister.hpp>
41 #include <boost/random/uniform_real.hpp>
42 #include <boost/random/normal_distribution.hpp>
43 #include <boost/random/variate_generator.hpp>
70 assert(lower_bound <= upper_bound);
71 return (upper_bound - lower_bound) * uni_() + lower_bound;
77 int r = (int)floor(
uniformReal((
double)lower_bound, (
double)(upper_bound) + 1.0));
78 return (r > upper_bound) ? upper_bound : r;
96 return normal_() * stddev + mean;
104 double halfNormalReal(
double r_min,
double r_max,
double focus = 3.0);
120 static void setSeed(boost::uint32_t seed);
126 static boost::uint32_t
getSeed(
void);
130 boost::mt19937 generator_;
131 boost::uniform_real<> uniDist_;
132 boost::normal_distribution<> normalDist_;
133 boost::variate_generator<boost::mt19937&, boost::uniform_real<> > uni_;
134 boost::variate_generator<boost::mt19937&, boost::normal_distribution<> > normal_;
double gaussian01(void)
Generate a random real using a normal distribution with mean 0 and variance 1.
static void setSeed(boost::uint32_t seed)
Set the seed for random number generation. Use this function to ensure the same sequence of random nu...
void quaternion(double value[4])
Uniform random unit quaternion sampling. The computed value has the order (x,y,z,w) ...
void eulerRPY(double value[3])
Uniform random sampling of Euler roll-pitch-yaw angles, each in the range (-pi, pi]. The computed value has the order (roll, pitch, yaw)
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_...
bool uniformBool(void)
Generate a random boolean.
RNG(void)
Constructor. Always sets a different random seed.
Random number generation. An instance of this class cannot be used by multiple threads at once (membe...
double uniformReal(double lower_bound, double upper_bound)
Generate a random real within given bounds: [lower_bound, upper_bound)
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...
static boost::uint32_t getSeed(void)
Get the seed used for random number generation. Passing the returned value to setSeed() at a subseque...
double uniform01(void)
Generate a random real between 0 and 1.
int uniformInt(int lower_bound, int upper_bound)
Generate a random integer within given bounds: [lower_bound, upper_bound].
double gaussian(double mean, double stddev)
Generate a random real using a normal distribution with given mean and variance.