Line data Source code
1 : #include "uniform_variable.hpp"
2 :
3 84 : UniformVariable::UniformVariable(void) : RandomVariable() {}
4 :
5 41 : UniformVariable::UniformVariable(unsigned int seed, double parameter1) {
6 41 : if (parameter1 < 0) {
7 1 : throw std::runtime_error("Parameter 1 must be positive.");
8 : }
9 40 : this->generator = std::mt19937(seed);
10 40 : this->parameter1 = parameter1;
11 40 : this->dist = std::uniform_int_distribution<int>(0, this->parameter1);
12 40 : }
13 :
14 1000 : double UniformVariable::getNextValue(void) { return dist(this->generator); }
15 :
16 164286 : double UniformVariable::getNextIntValue(void) { return dist(this->generator); }
|