-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRandomNumberGenerator.hpp
More file actions
37 lines (31 loc) · 945 Bytes
/
RandomNumberGenerator.hpp
File metadata and controls
37 lines (31 loc) · 945 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#ifndef RandomNumberGenerator_hpp
#define RandomNumberGenerator_hpp
#include<bits/stdc++.h>
#include<random>
using namespace std;
class RandomNumberGenerator {
public:
double upperBound = 10; // Appropriate boundaries
double lowerBound = -10;
random_device rd;
uniform_real_distribution<> pos_distr;
uniform_real_distribution<> coeff_distr;
mt19937 gen;
RandomNumberGenerator(){
gen = mt19937(rd());
pos_distr = uniform_real_distribution<>(lowerBound, upperBound);
coeff_distr = uniform_real_distribution<>(0, 1);
}
RandomNumberGenerator(double lowerBound, double upperBound) {
this->lowerBound = lowerBound;
this->upperBound = upperBound;
RandomNumberGenerator();
}
double getRandomPosition() {
return pos_distr(gen);
}
double getRandomCoefficient() {
return coeff_distr(gen);
}
};
#endif // RandomNumberGenerator_hpp