Public Member Functions | Private Attributes | List of all members
random_numbers::RandomNumberGenerator Class Reference

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. More...
 
double gaussian01 (void)
 Generate a random real using a normal distribution with mean 0 and variance 1. More...
 
boost::uint32_t getFirstSeed ()
 Allow the randomly generated seed to be saved so that experiments / benchmarks can be recreated in the future. More...
 
void quaternion (double value[4])
 Uniform random unit quaternion sampling. The computed value has the order (x,y,z,w) More...
 
 RandomNumberGenerator (boost::uint32_t seed)
 Constructor. Allow a seed to be specified for deterministic behaviour. More...
 
 RandomNumberGenerator (void)
 Constructor. Always sets a "random" random seed. More...
 
double uniform01 (void)
 Generate a random real between 0 and 1. More...
 
int uniformInteger (int min, int max)
 Generate an integer uniformly at random within a specified range (inclusive) More...
 
double uniformReal (double lower_bound, double upper_bound)
 Generate a random real within given bounds: [lower_bound, upper_bound) More...
 

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_
 

Detailed Description

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 86 of file random_numbers.h.

Constructor & Destructor Documentation

◆ RandomNumberGenerator() [1/2]

random_numbers::RandomNumberGenerator::RandomNumberGenerator ( void  )

Constructor. Always sets a "random" random seed.

Definition at line 73 of file random_numbers.cpp.

◆ RandomNumberGenerator() [2/2]

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.

Member Function Documentation

◆ gaussian()

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 150 of file random_numbers.h.

◆ gaussian01()

double random_numbers::RandomNumberGenerator::gaussian01 ( void  )
inline

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

Definition at line 144 of file random_numbers.h.

◆ getFirstSeed()

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.

◆ quaternion()

void random_numbers::RandomNumberGenerator::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

Definition at line 91 of file random_numbers.cpp.

◆ uniform01()

double random_numbers::RandomNumberGenerator::uniform01 ( void  )
inline

Generate a random real between 0 and 1.

Definition at line 128 of file random_numbers.h.

◆ uniformInteger()

int random_numbers::RandomNumberGenerator::uniformInteger ( int  min,
int  max 
)
inline

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

Definition at line 161 of file random_numbers.h.

◆ uniformReal()

double random_numbers::RandomNumberGenerator::uniformReal ( double  lower_bound,
double  upper_bound 
)
inline

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

Parameters
lower_boundThe lower bound
upper_boundThe upper bound

Definition at line 138 of file random_numbers.h.

Member Data Documentation

◆ generator_

boost::mt19937 random_numbers::RandomNumberGenerator::generator_
private

Definition at line 174 of file random_numbers.h.

◆ normal_

boost::variate_generator<boost::mt19937&, boost::normal_distribution<> > random_numbers::RandomNumberGenerator::normal_
private

Definition at line 178 of file random_numbers.h.

◆ normalDist_

boost::normal_distribution random_numbers::RandomNumberGenerator::normalDist_
private

Definition at line 176 of file random_numbers.h.

◆ uni_

boost::variate_generator<boost::mt19937&, boost::uniform_real<> > random_numbers::RandomNumberGenerator::uni_
private

Definition at line 177 of file random_numbers.h.

◆ uniDist_

boost::uniform_real random_numbers::RandomNumberGenerator::uniDist_
private

Definition at line 175 of file random_numbers.h.


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


random_numbers
Author(s): Ioan Sucan
autogenerated on Mon Oct 14 2024 02:13:08