47 : engine_(
seed), seed_(
seed), normal_(0.0, 1.0), uniform_(0.0, 1.0) {}
56 explicit RNG(std::seed_seq &seq)
57 : engine_(seq), seed_(0), normal_(0.0, 1.0), uniform_(0.0, 1.0) {}
86 return mean + stddev * normal_(engine_);
93 double uniform() {
return uniform_(engine_); }
102 return min + (max - min) * uniform_(engine_);
112 std::uniform_int_distribution<int64_t> dist(min, max);
113 return dist(engine_);
121 return Eigen::Vector3d(normal_(engine_), normal_(engine_),
131 Eigen::Vector<double, N> v;
132 for (
int i = 0; i < N; ++i) {
133 v(i) = normal_(engine_);
150 uint64_t
seed()
const {
return seed_; }
156 void discard(uint64_t n) { engine_.discard(n); }
175 engine_.seed(new_seed);
183 std::normal_distribution<double> normal_;
184 std::uniform_real_distribution<double> uniform_;
int64_t uniform_int(int64_t min, int64_t max)
Generate uniform integer [min, max].
Definition RNG.hpp:111
double uniform(double min, double max)
Generate uniform [min, max).
Definition RNG.hpp:101
Eigen::Vector< double, N > gaussianN()
Fill N-vector with independent N(0,1).
Definition RNG.hpp:130
RNG & operator=(RNG &&)=default
double gaussian()
Generate standard normal N(0,1).
Definition RNG.hpp:77
result_type operator()()
Get raw random bits.
Definition RNG.hpp:71
double gaussian(double mean, double stddev)
Generate normal N(mean, stddev).
Definition RNG.hpp:85
RNG(std::seed_seq &seq)
Construct with seed sequence.
Definition RNG.hpp:56
Engine & engine()
Access underlying engine (for advanced use).
Definition RNG.hpp:142
void reseed(uint64_t new_seed)
Reseed with new value.
Definition RNG.hpp:173
uint64_t seed() const
Get original seed (for logging/reproducibility).
Definition RNG.hpp:150
Engine::result_type result_type
Definition RNG.hpp:40
const Engine & engine() const
Definition RNG.hpp:143
RNG & operator=(const RNG &)=delete
RNG(uint64_t seed)
Construct with explicit seed.
Definition RNG.hpp:46
void reset()
Reset to initial state with same seed.
Definition RNG.hpp:163
std::mt19937_64 Engine
Definition RNG.hpp:39
double uniform()
Generate uniform [0, 1).
Definition RNG.hpp:93
Eigen::Vector3d gaussian3()
Fill 3-vector with independent N(0,1).
Definition RNG.hpp:120
void discard(uint64_t n)
Discard n values (for stream splitting).
Definition RNG.hpp:156
Definition Distributions.hpp:14