Unbias a random generator: Difference between revisions

Updated D entry
(Updated D entry)
(Updated D entry)
Line 374:
<lang d>import std.stdio, std.random, std.algorithm, std.range, std.functional;
 
boolenum biased = (in int n) /*nothrow*/ {=> uniform01 < (1.0 / n);
return uniform(0.0, 1.0) < (1.0 / n);
}
 
int unbiased(in int bias) /*nothrow*/ {