IoT-Simulator-Core/Sources/RandomCpp/NormalGenerator.cpp

33 lines
683 B
C++
Raw Normal View History

2024-12-01 12:10:19 +00:00
#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);
}