Skip to content

Commit 1e3da4f

Browse files
committed
add comment to random.h
1 parent c3acd3b commit 1e3da4f

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

common/random.h

+4
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,17 @@ struct Random {
6969
return T(lower + next(uint64_t(upper - lower)));
7070
}
7171

72+
// random choice from false or true
7273
bool uniform_bool() { return uniform(0, 1) == 1; }
7374

75+
// random choice from [0.0, 1.0]
7476
double uniform01() {
7577
uint64_t v = next(1ULL << 63);
7678
return double(v) / (1ULL << 63);
7779
}
7880

7981
// random choice non-empty sub-interval from interval [lower, upper)
82+
// equal: random choice 2 disjoint elements from [lower, upper]
8083
template <class T>
8184
std::pair<T, T> uniform_pair(T lower, T upper) {
8285
assert(upper - lower >= 1);
@@ -123,6 +126,7 @@ struct Random {
123126
return idx;
124127
}
125128

129+
// random choise n elements from [lower, upper]
126130
template <class T>
127131
std::vector<T> choice(size_t n, T lower, T upper) {
128132
assert(T(n) <= upper - lower + 1);

0 commit comments

Comments
 (0)