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 <rng.h>
|
void | ball (S r_min, S r_max, S &x, S &y, S &z) |
| Uniform random sample in a ball with radius from r_min to r_max. More...
|
|
void | disk (S r_min, S r_max, S &x, S &y) |
| Uniform random sample on a disk with radius from r_min to r_max. More...
|
|
void | eulerRPY (S 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) */. More...
|
|
S | gaussian (S mean, S stddev) |
| Generate a random real using a normal distribution with given mean and variance. More...
|
|
S | gaussian01 () |
| Generate a random real using a normal distribution with mean 0 and variance 1. More...
|
|
int | halfNormalInt (int r_min, int r_max, S 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() More...
|
|
S | halfNormalReal (S r_min, S r_max, S 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. More...
|
|
void | quaternion (S value[4]) |
| Uniform random unit quaternion sampling. The computed value has the order (x,y,z,w) More...
|
|
| RNG () |
| Constructor. Always sets a different random seed. More...
|
|
S | uniform01 () |
| Generate a random real between 0 and 1. More...
|
|
bool | uniformBool () |
| Generate a random boolean. More...
|
|
int | uniformInt (int lower_bound, int upper_bound) |
| Generate a random integer within given bounds: [lower_bound, upper_bound]. More...
|
|
S | uniformReal (S lower_bound, S upper_bound) |
| Generate a random real within given bounds: [lower_bound, upper_bound) More...
|
|
|
static std::uint_fast32_t | getSeed () |
| 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. More...
|
|
static void | setSeed (std::uint_fast32_t seed) |
| Set the seed for random number generation. Use this function to ensure the same sequence of random numbers is generated. More...
|
|
template<typename S>
class fcl::RNG< S >
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 58 of file rng.h.
◆ RNG()
Constructor. Always sets a different random seed.
Definition at line 52 of file rng-inl.h.
◆ ball()
template<typename S >
void fcl::RNG< S >::ball |
( |
S |
r_min, |
|
|
S |
r_max, |
|
|
S & |
x, |
|
|
S & |
y, |
|
|
S & |
z |
|
) |
| |
Uniform random sample in a ball with radius from r_min to r_max.
Definition at line 171 of file rng-inl.h.
◆ disk()
template<typename S >
void fcl::RNG< S >::disk |
( |
S |
r_min, |
|
|
S |
r_max, |
|
|
S & |
x, |
|
|
S & |
y |
|
) |
| |
Uniform random sample on a disk with radius from r_min to r_max.
Definition at line 159 of file rng-inl.h.
◆ eulerRPY()
template<typename S >
void fcl::RNG< S >::eulerRPY |
( |
S |
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) */.
Definition at line 150 of file rng-inl.h.
◆ gaussian()
template<typename S >
S fcl::RNG< S >::gaussian |
( |
S |
mean, |
|
|
S |
stddev |
|
) |
| |
Generate a random real using a normal distribution with given mean and variance.
Definition at line 98 of file rng-inl.h.
◆ gaussian01()
Generate a random real using a normal distribution with mean 0 and variance 1.
Definition at line 91 of file rng-inl.h.
◆ getSeed()
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.
Definition at line 213 of file rng-inl.h.
◆ halfNormalInt()
template<typename S >
int fcl::RNG< S >::halfNormalInt |
( |
int |
r_min, |
|
|
int |
r_max, |
|
|
S |
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()
Definition at line 122 of file rng-inl.h.
◆ halfNormalReal()
template<typename S >
S fcl::RNG< S >::halfNormalReal |
( |
S |
r_min, |
|
|
S |
r_max, |
|
|
S |
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.
Definition at line 105 of file rng-inl.h.
◆ quaternion()
template<typename S >
void fcl::RNG< S >::quaternion |
( |
S |
value[4] | ) |
|
Uniform random unit quaternion sampling. The computed value has the order (x,y,z,w)
Definition at line 132 of file rng-inl.h.
◆ setSeed()
template<typename S >
void fcl::RNG< S >::setSeed |
( |
std::uint_fast32_t |
seed | ) |
|
|
static |
Set the seed for random number generation. Use this function to ensure the same sequence of random numbers is generated.
Definition at line 192 of file rng-inl.h.
◆ uniform01()
Generate a random real between 0 and 1.
Definition at line 59 of file rng-inl.h.
◆ uniformBool()
Generate a random boolean.
Definition at line 84 of file rng-inl.h.
◆ uniformInt()
template<typename S >
int fcl::RNG< S >::uniformInt |
( |
int |
lower_bound, |
|
|
int |
upper_bound |
|
) |
| |
Generate a random integer within given bounds: [lower_bound, upper_bound].
Definition at line 75 of file rng-inl.h.
◆ uniformReal()
template<typename S >
S fcl::RNG< S >::uniformReal |
( |
S |
lower_bound, |
|
|
S |
upper_bound |
|
) |
| |
Generate a random real within given bounds: [lower_bound, upper_bound)
Definition at line 66 of file rng-inl.h.
◆ generator_
◆ normalDist_
template<typename S >
std::normal_distribution fcl::RNG< S >::normalDist_ |
|
private |
◆ uniDist_
template<typename S >
std::uniform_real_distribution fcl::RNG< S >::uniDist_ |
|
private |
The documentation for this class was generated from the following files: