20#ifndef RANDOMNUMBERGENERATOR_H
21#define RANDOMNUMBERGENERATOR_H
1214 virtual void getState(std::vector<uint64_t>& ovec_seed)
const = 0;
1215 virtual void setState(
const std::vector<uint64_t>& ivec_seed) = 0;
1220 uint64_t
combine32to64(
const uint32_t& low,
const uint32_t& high)
const;
1225 bool getEntropy(uint64_t& store)
const;
1226 uint64_t timeMixer(
const time_t& tt,
const clock_t& cc)
const;
1227 uint32_t hash(
const uint32_t& nn)
const;
1228 unsigned int countLeadingZeros(
const uint64_t& nn)
const;
1262 const std::vector<double>& distribution_params = std::vector<double>());
1271 double doub(
const RNG_BOUND& bounds,
const bool& true_double =
false);
1274 double pdf(
const double& xx);
1275 double cdf(
const double& xx);
1277 uint64_t
range64(
const uint64_t& aa,
const uint64_t& bb);
1278 uint32_t
range32(
const uint32_t& aa,
const uint32_t& bb);
1279 bool trueRange32(
const uint32_t& aa,
const uint32_t& bb, uint32_t& result,
1280 const unsigned int& nmax = 1e6);
1282 void getState(std::vector<uint64_t>& ovec_seed)
const;
1283 void setState(
const std::vector<uint64_t>& ivec_seed);
1287 std::vector<double>());
1302 std::vector<double> DistributionParameters;
1304 bool rng_muller_generate;
1305 double rng_muller_z1;
1313 double doubUniform();
1314 double pdfUniform(
const double& xx)
const;
1315 double cdfUniform(
const double& xx)
const;
1317 double pdfGauss(
const double& xx)
const;
1318 double cdfGauss(
const double& xx)
const;
1320 double doubChiSquare();
1321 double doubStudentT();
1325 double pdfNotImplemented(
const double& xx)
const;
1326 double cdfNotImplemented(
const double& xx)
const;
1328 double doubGaussKernel(
const double& mean,
const double& sigma);
1329 double doubGammaKernel(
const double& alpha,
const double& beta);
1330 double doubBetaKernel(
const double& alpha,
const double& beta);
1338 void getState(std::vector<uint64_t>& ovec_seed)
const;
1339 void setState(
const std::vector<uint64_t>& ivec_seed);
1343 uint64_t uu, vv, ww;
1345 bool initAllStates();
1353 void getState(std::vector<uint64_t>& ovec_seed)
const;
1354 void setState(
const std::vector<uint64_t>& ivec_seed);
1360 bool initAllStates();
1368 void getState(std::vector<uint64_t>& ovec_seed)
const;
1369 void setState(
const std::vector<uint64_t>& ivec_seed);
1372 const unsigned int MT_NN;
1373 const unsigned int MT_MM;
1374 unsigned int current_mt_index;
1376 std::vector<uint32_t> vec_states;
1378 bool initAllStates();
Definition: RandomNumberGenerator.h:1231
uint64_t int64()
Draw a 64 bit random number.
Definition: RandomNumberGenerator.cc:119
bool getHardwareSeedSuccess() const
Check if hardware noise could be read.
Definition: RandomNumberGenerator.cc:534
RandomNumberGenerator(const RNG_TYPE &type=RNG_XOR, const RNG_DISTR &distribution=RNG_UNIFORM, const std::vector< double > &distribution_params=std::vector< double >())
Default constructor.
Definition: RandomNumberGenerator.cc:44
double doub()
Draw a random number with double precision.
Definition: RandomNumberGenerator.cc:137
double draw()
Draw a random number with double precision.
Definition: RandomNumberGenerator.cc:176
uint64_t range64(const uint64_t &aa, const uint64_t &bb)
64 bit random number in an interval [aa, bb]
Definition: RandomNumberGenerator.cc:207
RNG_DISTR getDistribution(std::vector< double > &vec_params) const
Set the state of the RNG (seed the RNG)
Definition: RandomNumberGenerator.cc:287
static RNG_TYPE strToRngtype(const std::string &str)
Get an RNG_TYPE from a string.
Definition: RandomNumberGenerator.cc:625
std::string toString()
Print some info about the selected generator.
Definition: RandomNumberGenerator.cc:554
void setDistributionParameter(const std::string ¶m_name, const double ¶m_val)
Set single distribution parameter.
Definition: RandomNumberGenerator.cc:470
double getDistributionParameter(const std::string ¶m_name) const
Retrieve single distribution parameter.
Definition: RandomNumberGenerator.cc:407
void getState(std::vector< uint64_t > &ovec_seed) const
Get the state of the RNG to save for later continuation.
Definition: RandomNumberGenerator.cc:269
uint32_t int32()
Draw a 32 bit random number.
Definition: RandomNumberGenerator.cc:128
bool getUniqueSeed(uint64_t &store) const
Get a proper 64 bit seeding value for the generator.
Definition: RandomNumberGenerator.cc:545
RNG_BOUND
Definition: RandomNumberGenerator.h:1253
@ RNG_AINCBEXC
[0, 1)
Definition: RandomNumberGenerator.h:1255
@ RNG_AEXCBEXC
(0, 1)
Definition: RandomNumberGenerator.h:1257
@ RNG_AEXCBINC
(0, 1]
Definition: RandomNumberGenerator.h:1256
@ RNG_AINCBINC
[0, 1]
Definition: RandomNumberGenerator.h:1254
uint32_t range32(const uint32_t &aa, const uint32_t &bb)
32 bit random number in an interval [aa, bb]
Definition: RandomNumberGenerator.cc:232
void setState(const std::vector< uint64_t > &ivec_seed)
Set the state of the RNG (seed the RNG)
Definition: RandomNumberGenerator.cc:278
virtual ~RandomNumberGenerator()
Default destructor. Makes sure all states are freed from memory.
Definition: RandomNumberGenerator.cc:83
bool trueRange32(const uint32_t &aa, const uint32_t &bb, uint32_t &result, const unsigned int &nmax=1e6)
Random integer in a range without distribution distortions.
Definition: RandomNumberGenerator.cc:248
RNG_TYPE
Definition: RandomNumberGenerator.h:1234
@ RNG_XOR
Combined generator.
Definition: RandomNumberGenerator.h:1235
@ RNG_PCG
Permuted linear congruential generator.
Definition: RandomNumberGenerator.h:1236
@ RNG_MTW
Mersenne Twister generator.
Definition: RandomNumberGenerator.h:1237
double cdf(const double &xx)
Cumulative distribution function of selected distribution (integrated distribution function)
Definition: RandomNumberGenerator.cc:196
RNG_DISTR
Definition: RandomNumberGenerator.h:1242
@ RNG_GAMMA
Gamma deviates.
Definition: RandomNumberGenerator.h:1246
@ RNG_STUDENTT
Student-t deviates.
Definition: RandomNumberGenerator.h:1248
@ RNG_BETA
Beta deviates.
Definition: RandomNumberGenerator.h:1249
@ RNG_CHISQUARED
Chi-Squared deviates.
Definition: RandomNumberGenerator.h:1247
@ RNG_UNIFORM
Uniform deviates.
Definition: RandomNumberGenerator.h:1243
@ RNG_F
Fisher deviates.
Definition: RandomNumberGenerator.h:1250
@ RNG_NORMAL
= RNG_GAUSS
Definition: RandomNumberGenerator.h:1245
@ RNG_GAUSS
Gaussian deviates.
Definition: RandomNumberGenerator.h:1244
void setDistribution(const RNG_DISTR &distribution, const std::vector< double > &vec_params=std::vector< double >())
Set the distribution to draw random numbers from.
Definition: RandomNumberGenerator.cc:302
RandomNumberGenerator & operator=(const RandomNumberGenerator &rng)
Copy-operator.
Definition: RandomNumberGenerator.cc:94
double pdf(const double &xx)
Probability density function of selected distribution.
Definition: RandomNumberGenerator.cc:186
static RNG_DISTR strToRngdistr(const std::string &str)
Get an RNG_DISTR from a string.
Definition: RandomNumberGenerator.cc:646
Definition: RandomNumberGenerator.h:1205
bool hardware_seed_success
Definition: RandomNumberGenerator.h:1207
virtual uint32_t int32()=0
bool getUniqueSeed(uint64_t &store) const
Definition: RandomNumberGenerator.cc:1148
uint64_t combine32to64(const uint32_t &low, const uint32_t &high) const
Definition: RandomNumberGenerator.cc:1168
virtual void setState(const std::vector< uint64_t > &ivec_seed)=0
virtual void getState(std::vector< uint64_t > &ovec_seed) const =0
double doubFromInt(const uint64_t &rn) const
Definition: RandomNumberGenerator.cc:1175
virtual uint64_t int64()=0
virtual ~RngCore()
Definition: RandomNumberGenerator.cc:1142
RngCore()
Definition: RandomNumberGenerator.cc:1136
double trueDoub()
Definition: RandomNumberGenerator.cc:1184
Definition: RandomNumberGenerator.h:1381
static RngCore * getCore(const RandomNumberGenerator::RNG_TYPE &algorithm)
Definition: RandomNumberGenerator.cc:1273
Definition: RandomNumberGenerator.h:1363
void getState(std::vector< uint64_t > &ovec_seed) const
Definition: RandomNumberGenerator.cc:1008
uint32_t int32()
Definition: RandomNumberGenerator.cc:1039
RngMtw()
Definition: RandomNumberGenerator.cc:990
void setState(const std::vector< uint64_t > &ivec_seed)
Definition: RandomNumberGenerator.cc:1017
uint64_t int64()
Definition: RandomNumberGenerator.cc:1001
Definition: RandomNumberGenerator.h:1348
RngPcg()
Definition: RandomNumberGenerator.cc:924
uint32_t int32()
Definition: RandomNumberGenerator.cc:939
uint64_t int64()
Definition: RandomNumberGenerator.cc:930
void getState(std::vector< uint64_t > &ovec_seed) const
Definition: RandomNumberGenerator.cc:959
void setState(const std::vector< uint64_t > &ivec_seed)
Definition: RandomNumberGenerator.cc:966
Definition: RandomNumberGenerator.h:1333
uint64_t int64()
Definition: RandomNumberGenerator.cc:868
void getState(std::vector< uint64_t > &ovec_seed) const
Definition: RandomNumberGenerator.cc:886
void setState(const std::vector< uint64_t > &ivec_seed)
Definition: RandomNumberGenerator.cc:895
RngXor()
Definition: RandomNumberGenerator.cc:862
uint32_t int32()
Definition: RandomNumberGenerator.cc:881