Line data Source code
1 : #include "uniform_variable.hpp"
2 : #include "numeric.hpp"
3 :
4 0 : UniformVariable::UniformVariable(void) : RandomVariable() {}
5 :
6 35 : UniformVariable::UniformVariable(unsigned int seed, double parameter1) {
7 35 : if (parameter1 < 0) {
8 10 : throw std::runtime_error("Parameter 1 must be non-negative.");
9 : }
10 : const int upperBound =
11 25 : fnsim_numeric::doubleToInt(parameter1, "uniform upper bound");
12 16 : this->generator = std::mt19937(seed);
13 16 : this->parameter1 = parameter1;
14 16 : this->dist = std::uniform_int_distribution<int>(0, upperBound);
15 16 : }
16 :
17 600 : double UniformVariable::getNextValue(void) { return dist(this->generator); }
18 1600 : double UniformVariable::getNextIntValue(void) { return dist(this->generator); }
|