NetDEM v1.0
Loading...
Searching...
No Matches
distribution_uniform.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "distribution.hpp"
4#include <random>
5
6namespace netdem {
7
16public:
21
30 std::random_device rd;
31 mt_eng = std::mt19937(rd());
32 real_dist = std::uniform_real_distribution<double>(0, 1);
33 }
34
48 std::random_device rd;
49 mt_eng = std::mt19937(rd());
50 real_dist = std::uniform_real_distribution<double>(bound_min, bound_max);
51 }
52
58 double Get() override { return real_dist(mt_eng); }
59
70 VecXT<double> Get(int num) override {
71 VecXT<double> num_list(num, 0);
72
73 for (int i = 0; i < num; i++) {
74 num_list[i] = real_dist(mt_eng);
75 }
76
77 return num_list;
78 }
79
80private:
81 std::mt19937 mt_eng;
82 std::uniform_real_distribution<double>
83 real_dist;
84};
85
86} // namespace netdem
Definition distribution.hpp:10
Generates random numbers from a uniform distribution.
Definition distribution_uniform.hpp:15
double bound_min
Lower and upper bounds of the uniform distribution.
Definition distribution_uniform.hpp:20
double bound_max
Definition distribution_uniform.hpp:20
VecXT< double > Get(int num) override
Get multiple random numbers from the uniform distribution.
Definition distribution_uniform.hpp:70
double Get() override
Get a single random number from the uniform distribution.
Definition distribution_uniform.hpp:58
UniformDistribution(double bound_min, double bound_max)
Constructor that takes bounds as input parameters.
Definition distribution_uniform.hpp:46
UniformDistribution()
Default constructor.
Definition distribution_uniform.hpp:29
Definition bond_entry.hpp:7
std::vector< T > VecXT
Definition utils_macros.hpp:31