File tree 1 file changed +4
-0
lines changed
1 file changed +4
-0
lines changed Original file line number Diff line number Diff line change @@ -69,14 +69,17 @@ struct Random {
69
69
return T (lower + next (uint64_t (upper - lower)));
70
70
}
71
71
72
+ // random choice from false or true
72
73
bool uniform_bool () { return uniform (0 , 1 ) == 1 ; }
73
74
75
+ // random choice from [0.0, 1.0]
74
76
double uniform01 () {
75
77
uint64_t v = next (1ULL << 63 );
76
78
return double (v) / (1ULL << 63 );
77
79
}
78
80
79
81
// random choice non-empty sub-interval from interval [lower, upper)
82
+ // equal: random choice 2 disjoint elements from [lower, upper]
80
83
template <class T >
81
84
std::pair<T, T> uniform_pair (T lower, T upper) {
82
85
assert (upper - lower >= 1 );
@@ -123,6 +126,7 @@ struct Random {
123
126
return idx;
124
127
}
125
128
129
+ // random choise n elements from [lower, upper]
126
130
template <class T >
127
131
std::vector<T> choice (size_t n, T lower, T upper) {
128
132
assert (T (n) <= upper - lower + 1 );
You can’t perform that action at this time.
0 commit comments