44 for (
int thread = 0; thread < nThreads; ++thread) {
61 const double max = 1.0) {
62 return Engine()->Uniform(min, max);
67 return Engine()->Integer(max - min + 1) + min;
71 double Gaus(
const double mean = 0.0,
72 const double sigma = 1.0) {
73 return Engine()->Gaus(mean, sigma);
78 return Engine()->PoissonD(mean);
83 #pragma GCC diagnostic push
84 #pragma GCC diagnostic ignored "-Wconversion"
85 return Engine()->Poisson(mean);
86 #pragma GCC diagnostic pop
97 return static_cast<std::size_t
>(omp_get_thread_num());
111 inline void SetSeed(
const std::uint64_t seed) {
117 const double max = 1.0) {
137 inline double Gaus(
const double mean = 0.0,
138 const double sigma = 1.0) {
KS: Core MaCh3 definitions and compile-time configuration utilities.
#define _MaCh3_Safe_Include_Start_
KS: Avoiding warning checking for headers.
#define _MaCh3_Safe_Include_End_
System and monitoring utilities for printing system information and status updates.
Universal random number generator for MaCh3.
static Random & Instance()
Get the global Random instance.
void SetSeed(const std::uint64_t seed)
Set the global seed and initialise all RNG streams.
double Uniform(const double min=0.0, const double max=1.0)
Generate a uniform random number in [min, max).
std::uint64_t GetSeed() const
Get the global seed.
double Gaus(const double mean=0.0, const double sigma=1.0)
Generate a Gaussian random number.
TRandom3 * Engine()
Get the random generator associated with the current thread.
int Poisson(const double mean)
Generate an integer Poisson-distributed random number with the given mean.
static std::size_t ThreadID()
Get the current OpenMP thread ID.
int UniformInt(const int min, const int max)
Generate a uniform random integer in [min, max].
std::uint64_t fSeed
The global seed.
double PoissonD(const double mean)
Generate a double-precision Poisson-distributed random number with the given mean.
std::vector< std::unique_ptr< TRandom3 > > fEngines
One random generator per thread.
void SetSeed(const std::uint64_t seed)
Set the global random seed.
double PoissonD(const double mean)
Generate a Poisson-distributed random number with the given mean.
double Uniform(const double min=0.0, const double max=1.0)
Generate a uniform random number in [min, max).
int Poisson(const double mean)
Generate a Poisson-distributed integer with the given mean.
double Gaus(const double mean=0.0, const double sigma=1.0)
Generate a Gaussian random number.
int UniformInt(const int min, const int max)
Generate a uniform random integer in [min, max].
int GetNThreads()
number of threads which we need for example for TRandom3