![]() |
CosmoBolognaLib
Free Software C++/Python libraries for cosmological calculations
|
The class RandomNumbers. More...
#include <RandomNumbers.h>
Public Member Functions | |
RandomNumbers ()=default | |
default constructor | |
RandomNumbers (const int seed, const double MinVal=par::defaultDouble, const double MaxVal=-par::defaultDouble) | |
constructor More... | |
virtual | ~RandomNumbers ()=default |
default destructor | |
virtual double | operator() ()=0 |
extract number from the distribution More... | |
void | set_seed (const int seed) |
set the random number generator seed More... | |
void | set_range (const double MinVal, const double MaxVal) |
set the range for the random number extraction More... | |
void | set_value (const double value) |
set the value for constant distribution More... | |
virtual void | set_mean (const double mean) |
set the mean for Poisson distribution More... | |
virtual void | set_mean_sigma (const double mean, const double sigma) |
set parameters for Normal distribution More... | |
virtual void | set_discrete_values (const std::vector< double > values, const std::vector< double > weights) |
set parameters for Discrete distribution More... | |
virtual void | set_interpolated_distribution (const std::vector< double > values, const std::vector< double > weights) |
set the parameters for the interpolated distribution More... | |
virtual void | set_custom_distribution (const distribution_func func, const std::shared_ptr< void > modelInput, const std::vector< double > parameter) |
set parameters for interpolated distribution More... | |
Protected Attributes | |
std::mt19937_64 | m_generator |
pseudo-random numbers generator | |
int | m_seed |
seed | |
double | m_MinVal |
minimum value to generate | |
double | m_MaxVal |
maximum value to generate | |
The class RandomNumbers.
"Headers/RandomNumbers.h"
The base class to generate random numbers
Definition at line 77 of file RandomNumbers.h.
cbl::random::RandomNumbers::RandomNumbers | ( | const int | seed, |
const double | MinVal = par::defaultDouble , |
||
const double | MaxVal = -par::defaultDouble |
||
) |
constructor
seed | the random number generator seed |
MinVal | lower limit of the random numbers range |
MaxVal | upper limit of the random numbers range |
Definition at line 45 of file RandomNumbers.cpp.
|
pure virtual |
extract number from the distribution
Implemented in cbl::random::CustomDistributionRandomNumbers, cbl::random::DistributionRandomNumbers, cbl::random::DiscreteRandomNumbers, cbl::random::NormalRandomNumbers, cbl::random::PoissonRandomNumbers, cbl::random::UniformRandomNumbers_Int, cbl::random::UniformRandomNumbers, and cbl::random::ConstantRandomNumbers.
|
inlinevirtual |
set parameters for interpolated distribution
func | the probability distribution function |
modelInput | pointer to the data possibly used to construct the probability distribution function |
parameter | the parameters of the probability distribution function |
Reimplemented in cbl::random::CustomDistributionRandomNumbers.
Definition at line 186 of file RandomNumbers.h.
|
inlinevirtual |
set parameters for Discrete distribution
values | the values to be extracted |
weights | the values weights |
Reimplemented in cbl::random::DiscreteRandomNumbers.
Definition at line 164 of file RandomNumbers.h.
|
inlinevirtual |
set the parameters for the interpolated distribution
values | the values to be extracted |
weights | the values weights |
Definition at line 172 of file RandomNumbers.h.
|
inlinevirtual |
set the mean for Poisson distribution
mean | the Poisson distribution mean |
Reimplemented in cbl::random::PoissonRandomNumbers.
Definition at line 148 of file RandomNumbers.h.
|
inlinevirtual |
set parameters for Normal distribution
mean | the Normal distribution mean |
sigma | the Normal distribution standard deviation |
Reimplemented in cbl::random::NormalRandomNumbers.
Definition at line 156 of file RandomNumbers.h.
void cbl::random::RandomNumbers::set_range | ( | const double | MinVal, |
const double | MaxVal | ||
) |
set the range for the random number extraction
MinVal | lower limit of the random numbers range |
MaxVal | upper limit of the random numbers range |
Definition at line 65 of file RandomNumbers.cpp.
void cbl::random::RandomNumbers::set_seed | ( | const int | seed | ) |
set the random number generator seed
seed | the random number generator seed |
Definition at line 55 of file RandomNumbers.cpp.
|
inline |
set the value for constant distribution
value | the value to be returned |
Definition at line 141 of file RandomNumbers.h.