Unbias a random generator: Difference between revisions

Content added Content deleted
No edit summary
Line 651: Line 651:
end function
end function
</lang>
</lang>

Output:
Output:
<pre>
Biased bit-string, '1' chosen once out of 3 times . . .
Biased bit-string, '1' chosen once out of 3 times . . .
664236 zeros & 335764 ones. Ratio =0.335764
664236 zeros & 335764 ones. Ratio =0.335764
Line 671: Line 673:
Unbiased bit-string . . .
Unbiased bit-string . . .
500407 zeros & 499593 ones. Ratio =0.499593
500407 zeros & 499593 ones. Ratio =0.499593
</pre>





=={{header|Lua}}==
=={{header|Lua}}==