36 explicit PRG(
unsigned int seed);
41 inline unsigned int seed()
const 51 { std::bernoulli_distribution b(p);
return b(m_mteng); }
57 {
return m_bernoulli(m_mteng); }
64 { std::uniform_real_distribution<T> d(min, max);
return d(m_mteng); }
70 { std::uniform_int_distribution<int> d(min, max);
return d(m_mteng); }
75 inline size_t uniform(
size_t min,
size_t max)
76 { std::uniform_int_distribution<size_t> d(min, max);
return d(m_mteng); }
83 { std::uniform_real_distribution<T> d(0, max);
return d(m_mteng); }
89 { std::uniform_int_distribution<int> d(0, max);
return d(m_mteng); }
95 { std::uniform_int_distribution<size_t> d(0, max);
return d(m_mteng); }
101 {
return m_doubleZeroOne(m_mteng); }
106 template <
typename T>
107 inline T
uniform(std::uniform_real_distribution<T> d)
108 {
return d(m_mteng); }
113 template <
typename T>
115 {
return d(m_mteng); }
118 const unsigned int m_seed;
119 std::mt19937 m_mteng;
120 std::uniform_real_distribution<double> m_doubleZeroOne;
121 std::bernoulli_distribution m_bernoulli;
T uniform(T min, T max)
Generates a random double/float [min, max).
Definition: prg.h:63
bool bernoulli(double p)
Bernoulli distribution.
Definition: prg.h:50
T uniform(std::uniform_real_distribution< T > d)
Uniform continuous distribution for random numbers.
Definition: prg.h:107
double uniform()
Generates a random double [0, 1).
Definition: prg.h:100
unsigned int seed() const
Gets the initial PRG seed.
Definition: prg.h:41
int uniform(int min, int max)
Generates a random integer [min, max].
Definition: prg.h:69
size_t uniform(size_t min, size_t max)
Generates a random size_t [min, max].
Definition: prg.h:75
int uniform(int max)
Generates a random integer [0, max].
Definition: prg.h:88
size_t uniform(size_t max)
Generates a random size_t [0, max].
Definition: prg.h:94
bool bernoulli()
randBernoulli(p=0.5) alias.
Definition: prg.h:56
T uniform(std::uniform_int_distribution< T > d)
Uniform discrete distribution for random numbers.
Definition: prg.h:114
Pseudo-random number generator.
Definition: prg.h:29
PRG(unsigned int seed)
PRG constructor.
Definition: abstractgraph.h:29
T uniform(T max)
Generates a random double/float [0, max).
Definition: prg.h:82