March 2014 update
This commit is contained in:
parent
09687c4926
commit
a25938f123
1846 changed files with 21876 additions and 5203 deletions
|
|
@ -1,7 +1,7 @@
|
|||
import std.stdio, std.random, std.algorithm;
|
||||
|
||||
double random01(ref Xorshift rng) {
|
||||
immutable r = rng.front / cast(double)rng.max;
|
||||
immutable r = rng.front / double(rng.max);
|
||||
rng.popFront;
|
||||
return r;
|
||||
}
|
||||
|
|
@ -14,7 +14,7 @@ struct SOfN(size_t n) {
|
|||
i++;
|
||||
if (i <= n)
|
||||
sample[i - 1] = item;
|
||||
else if (rng.random01 < (cast(double)n / i))
|
||||
else if (rng.random01 < (double(n) / i))
|
||||
sample[uniform(0, n, rng)] = item;
|
||||
return sample[0 .. min(i, $)];
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue