17namespace environment::field::aggregation
24 explicit Random(std::uint64_t seed)
30 double Uniform() {
return static_cast<double>(m_engine() >> 11U) * (1.0 / 9007199254740992.0); }
33 double Uniform(
double low,
double high) {
return low + (high - low) *
Uniform(); }
38 const double u1 = 1.0 -
Uniform();
40 return std::sqrt(-2.0 * std::log(u1)) * std::cos(2.0 * std::numbers::pi * u2);
44 double Normal(
double mean,
double sigma) {
return mean + sigma *
Normal(); }
50 std::mt19937_64 m_engine;
One random stream. Not thread-safe.
Definition Random.h:22
double LogNormal(double mu, double sigma)
exp(Normal(mu, sigma)).
Definition Random.h:47
double Uniform()
Uniform in [0, 1), 53 bits.
Definition Random.h:30
double Normal(double mean, double sigma)
Normal with a mean and a standard deviation.
Definition Random.h:44
double Uniform(double low, double high)
Uniform in [low, high).
Definition Random.h:33
double Normal()
Standard normal (Box-Muller, one value per two uniforms; the sine partner is discarded).
Definition Random.h:36