Helios++
Helios software for LiDAR simulations
|
Class to generate random numbers. More...
#include <RandomnessGenerator.h>
Public Member Functions | |
RandomnessGenerator () | |
Creates a RandomnessGenerator which will use an automatically computed seed. | |
RandomnessGenerator (double seed) | |
Creates a RandomnessGenerator which will use a double seed. More... | |
RandomnessGenerator (float seed) | |
Like RandomnessGenerator(double) constructor, the float is casted to a double. More... | |
RandomnessGenerator (long seed) | |
Creates a RandomnessGenerator which will use a long seed. More... | |
RandomnessGenerator (int seed) | |
Like RandomnessGenerator(long) constructor, the integer is casted to a long. More... | |
RandomnessGenerator (std::string const &seedstr) | |
Creates a RandomnessGenerator by parsing the string to automatically extract the seed and define the mode. More... | |
RandomnessGenerator (RandomnessGenerator const &rg) | |
Copy constructor for RandomnessGenerator. More... | |
RandomnessGenerator (RandomnessGenerator &&rg) noexcept | |
Move constructor for RandomnessGenerator. More... | |
RandomnessGenerator & | operator= (RandomnessGenerator const &rg) |
Copy assignment operator. More... | |
RandomnessGenerator & | operator= (RandomnessGenerator &&rg) |
Move assignment operator. More... | |
void | swap (RandomnessGenerator &rgA, RandomnessGenerator &rgB) |
Swap two RandomnessGenerator. More... | |
void | computeUniformRealDistribution (RealType lowerBound, RealType upperBound) |
Compute a uniform real distribution using the specified real data type. More... | |
RealType | uniformRealDistributionNext () |
Obtain the next value in the computed uniform real distribution. More... | |
void | computeNormalDistribution (RealType mean, RealType stdev) |
Compute a normal distribution using the specified real data type. More... | |
RealType | normalDistributionNext () |
Obtain the next value in the computed normal distribution. More... | |
Protected Member Functions | |
double | getDoubleSeed () |
Obtain the seed in double format. This getter is expected to be used with mode FIXED_SEED_DOUBLE. More... | |
long | getLongSeed () |
Obtain the seed in long format. This getter is expected to be used with mode FIXED_SEED_LONG. More... | |
Protected Attributes | |
std::string | mode |
RandomnessGenerator mode. More... | |
double | doubleSeed = 0 |
Double seed for randomness. | |
long | longSeed = 0 |
Long seed for randomness. | |
std::unique_ptr< std::mt19937 > | urdGen = nullptr |
Uniform Real Distribution Generator. | |
std::unique_ptr< std::uniform_real_distribution< RealType > > | urd = nullptr |
Uniform Real Distribution. | |
std::unique_ptr< std::mt19937 > | ndGen = nullptr |
Normal Distribution Generator. | |
std::unique_ptr< std::normal_distribution< RealType > > | nd = nullptr |
Normal Distribution. | |
Class to generate random numbers.
RealType | Type of the generated real random numbers. For instance double or float. |
|
inlineexplicit |
Creates a RandomnessGenerator which will use a double seed.
seed | The double seed to be used |
|
inlineexplicit |
Like RandomnessGenerator(double) constructor, the float is casted to a double.
|
inlineexplicit |
Creates a RandomnessGenerator which will use a long seed.
seed | The long seed to be used |
|
inlineexplicit |
Like RandomnessGenerator(long) constructor, the integer is casted to a long.
|
explicit |
Creates a RandomnessGenerator by parsing the string to automatically extract the seed and define the mode.
seedstr | String containing the seed. It can be a long integer, a double decimal or a timestamp string in "YYYY-mm-DD HH:MM:SS" format. NOTICE timestamp CANNOT specify a date before 1970-01-01 00:00:00. It would lead to undefined behaviors. |
RandomnessGenerator< RealType >::RandomnessGenerator | ( | RandomnessGenerator< RealType > const & | rg | ) |
Copy constructor for RandomnessGenerator.
Internal components will be copied preserving their status. So, when obtaining the next value from a distribution, it will be computed starting at the last considered value for the copied randomness generator.
rg | RandomnessGenerator to be copied |
|
noexcept |
Move constructor for RandomnessGenerator.
rg | RandomnessGenerator to be moved |
void RandomnessGenerator< RealType >::computeNormalDistribution | ( | RealType | mean, |
RealType | stdev | ||
) |
Compute a normal distribution using the specified real data type.
mean | The mean value for the normal distribution |
stdev | The standard deviation value for the normal distribution |
void RandomnessGenerator< RealType >::computeUniformRealDistribution | ( | RealType | lowerBound, |
RealType | upperBound | ||
) |
Compute a uniform real distribution using the specified real data type.
lowerBound | No less than lower bound values are allowed |
upperBound | No greater than upper bound values are allowed |
|
inlineprotected |
Obtain the seed in double format. This getter is expected to be used with mode FIXED_SEED_DOUBLE.
|
inlineprotected |
Obtain the seed in long format. This getter is expected to be used with mode FIXED_SEED_LONG.
RealType RandomnessGenerator< RealType >::normalDistributionNext | ( | ) |
Obtain the next value in the computed normal distribution.
If no normal distribution has been computed, then it is computed before obtaining the first element in the distribution. When normal distribution is computed by this method, its mean is 0 and its standard deviation is 1
RandomnessGenerator< RealType > & RandomnessGenerator< RealType >::operator= | ( | RandomnessGenerator< RealType > const & | rg | ) |
Copy assignment operator.
rg | RandomnessGenerator to be copied |
RandomnessGenerator< RealType > & RandomnessGenerator< RealType >::operator= | ( | RandomnessGenerator< RealType > && | rg | ) |
Move assignment operator.
rg | RandomnessGenerator to be moved |
void RandomnessGenerator< RealType >::swap | ( | RandomnessGenerator< RealType > & | rgA, |
RandomnessGenerator< RealType > & | rgB | ||
) |
Swap two RandomnessGenerator.
rgA | RandomnessGenerator to be swapped with rgB |
rgB | RandomnessGenerator to be swapped with rgA |
RealType RandomnessGenerator< RealType >::uniformRealDistributionNext | ( | ) |
Obtain the next value in the computed uniform real distribution.
If no uniform real distribution has been computed, then it is computed before obtaining the first element in the distribution. When uniform real distribution is computed by this method, it is bounded inside interval [0, 1]
|
protected |
RandomnessGenerator mode.
Specify the mode for the RandomnessGenerator.
Available modes are:
AUTO_SEED : Use and automatically computed seed
FIXED_SEED_DOUBLE : Use a fixed double decimal seed.
FIXED_SEED_LONG : Use a fixed long integer seed.<br/