-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDistributions.h
97 lines (78 loc) · 2.49 KB
/
Distributions.h
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#ifndef INTERSORT_DISTRIBUTIONS_H
#define INTERSORT_DISTRIBUTIONS_H
#include "Helpers.h"
namespace Intersort
{
template<typename T>
T randNumber(int low, int high)
{
std::mt19937 randomSeed;
randomSeed.seed(std::random_device()());
std::uniform_real_distribution<T> tempDist(low, high);
return tempDist(randomSeed);
}
template<>
int randNumber(int low, int high)
{
std::mt19937 randomSeed;
randomSeed.seed(std::random_device()());
std::uniform_int_distribution<int> tempDist(low, high);
return tempDist(randomSeed);
}
template<typename T>
std::vector<T> uniformDistribution(int len, int low, int high)
{
std::mt19937 randomSeed;
randomSeed.seed(std::random_device()());
std::uniform_real_distribution<T> tempDist(low, high);
std::vector<T> numbers;
for(int i = 0; i < len; i++)
numbers.push_back(tempDist(randomSeed));
return numbers;
}
template<>
std::vector<int> uniformDistribution(int len, int low, int high)
{
std::mt19937 randomSeed;
randomSeed.seed(std::random_device()());
std::uniform_int_distribution<int> tempDist(low, high);
std::vector<int> numbers;
for(int i = 0; i < len; i++)
numbers.push_back(tempDist(randomSeed));
return numbers;
}
template<typename T>
std::vector<int> poissonDistribution(int len, T mean)
{
std::mt19937 randomSeed;
randomSeed.seed(std::random_device()());
std::poisson_distribution<int> tempDist(mean);
std::vector<int> numbers;
for(int i = 0; i < len; i++)
numbers.push_back(tempDist(randomSeed));
return numbers;
}
template<typename T>
std::vector<T> exponentialDistribution(int len, T m)
{
std::mt19937 randomSeed;
randomSeed.seed(std::random_device()());
std::exponential_distribution<T> dist(m);
std::vector<T> numbers;
for(int i = 0; i < len; i++)
numbers.push_back(dist(randomSeed));
return numbers;
}
template<typename T>
std::vector<T> normalDistribution(int len, T m, T s)
{
std::mt19937 randomSeed;
randomSeed.seed(std::random_device()());
std::normal_distribution<T> normalDist(m, s);
std::vector<T> numbers;
for(int i = 0; i < len; i++)
numbers.push_back(normalDist(randomSeed));
return numbers;
}
}
#endif