Unbias a random generator: Difference between revisions
→{{header|Ruby}}: Too much ones, not enough zeros...changed rand_n
(→{{header|Ruby}}: Added Ruby sample) |
(→{{header|Ruby}}: Too much ones, not enough zeros...changed rand_n) |
||
Line 1,277:
=={{header|Ruby}}==
<lang ruby>def rand_n(bias)
rand(bias)
end
Line 1,301:
<pre>
bias biased unbiased
3 333043 500161
4 249133 499393
5 199767 500354
6 166163 499809
</pre>
=={{header|Seed7}}==
<lang seed7>$ include "seed7_05.s7i";
|