forked from lmluque/abm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Random.cpp
42 lines (34 loc) · 1.08 KB
/
Random.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
/*! \file Random.cpp
* \brief Archivo de implementación de la clase RNG
* \author Luciana Luque <[email protected]>
* \version 1.0
* \date 2020.06.09
*/
#include "Random.h"
RNG::RNG() : n_max(1.0), seed(13), media(1.0), std_desv(0.25) {}
/*
RNG::RNG(double NM, int SD) : n_max(NM), seed(SD),
dist(std::uniform_real_distribution<double>(0.0, NM)) {
generator.seed(seed);
}
*/
RNG::RNG(double NM, int SD, double med, double desv) : n_max(NM), seed(SD), media(med), std_desv(desv),
dist(std::uniform_real_distribution<double>(0.0, NM)), d(std::normal_distribution<double>(media,std_desv)) {
generator.seed(seed);
}
double RNG::RandomNumber() {
return dist(generator);
};
double RNG::NormalRandom(){
return d(generator);
}
double RNG::NormalRandom_CM( double mean, double standard_deviation )
{
std::normal_distribution<double> d2(mean,standard_deviation);
return d2(generator);
}
double RNG::RandomNumber( double min, double max )
{
std::uniform_real_distribution<double> dist2(min,max);
return dist2(generator);
}