Unverified Commit a06899ab authored by shiyu1994's avatar shiyu1994 Committed by GitHub
Browse files

fix Reservoir Sampling in Sample of random.h (#4450)

parent e36cc9c1
......@@ -82,13 +82,10 @@ class Random {
ret.push_back(i);
}
}
} else if (K == 1) {
int v = NextInt(0, N);
ret.push_back(v);
} else {
std::set<int> sample_set;
for (int r = N - K; r < N; ++r) {
int v = NextInt(0, r);
int v = NextInt(0, r + 1);
if (!sample_set.insert(v).second) {
sample_set.insert(r);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment