33 lines
683 B
C++
33 lines
683 B
C++
#include <random>
|
|
#include <chrono>
|
|
#include <GaussianRNG.h>
|
|
|
|
|
|
GaussianRNG::
|
|
GaussianRNG(
|
|
float mean,
|
|
float std_dev,
|
|
unsigned seed
|
|
) {
|
|
this->seed = seed;
|
|
this->generator = std::default_random_engine(this->seed);
|
|
this->distribution = std::normal_distribution<float>(mean, std_dev);
|
|
}
|
|
|
|
GaussianRNG
|
|
::GaussianRNG(
|
|
float mean,
|
|
float std_dev
|
|
) {
|
|
this->seed = std::chrono::system_clock::now().time_since_epoch().count();
|
|
this->generator = std::default_random_engine(this->seed);
|
|
this->distribution = std::normal_distribution<float>(mean, std_dev);
|
|
}
|
|
|
|
float GaussianRNG
|
|
::generate() {
|
|
return distribution(generator);
|
|
}
|
|
|
|
|