-
Notifications
You must be signed in to change notification settings - Fork 0
/
RNG.cpp
49 lines (43 loc) · 997 Bytes
/
RNG.cpp
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
38
39
40
41
42
43
44
45
46
47
48
//
// Created by root on 16.11.16.
//
#include "RNG.h"
RNG::RNG(int seed) {
setseed(seed);
printseed();
}
void RNG::setseed(int newSeed){
seed = newSeed;
re.seed(seed);
}
void RNG::printseed() {
std::cout << "Current seed is: " << seed << "\n";
}
RNG::~RNG() {
}
//////
// Integer
//////
std::vector<int> RNG::runif(int minNum, int maxNum, int n) {
std::vector<int> vec (n);
for (int i = 0; i < n; ++i){
vec[i] = dui(re, distUnifInt::param_type{minNum, maxNum});
}
return vec;
}
int RNG::runif(int minNum, int maxNum) {
return dui(re, distUnifInt::param_type{minNum, maxNum});
}
//////
// Double
//////
std::vector<double> RNG::runif(double minNum, double maxNum, int n) {
std::vector<double> vec (n);
for (int i = 0; i < n; ++i){
vec[i] = dud(re, distUnifDbl::param_type{minNum, maxNum});
}
return vec;
}
double RNG::runif(double minNum, double maxNum) {
return dud(re, distUnifDbl::param_type{minNum, maxNum});
}