Unbias a random generator: Difference between revisions
Content added Content deleted
m (→{{header|PARI/GP}}: clarify) |
m (→{{header|PARI/GP}}: trivia) |
||
Line 831: | Line 831: | ||
=={{header|PARI/GP}}== |
=={{header|PARI/GP}}== |
||
GP's random number generation is high-quality, using Brent's [http://maths.anu.edu.au/~brent/random.html XORGEN]. Thus this program is slow: the required 400,000 unbiased numbers |
GP's random number generation is high-quality, using Brent's [http://maths.anu.edu.au/~brent/random.html XORGEN]. Thus this program is slow: the required 400,000 unbiased numbers generated through this bias/unbias scheme take nearly a second. This requires about two million calls to <code>random</code>, which in turn generate a total of about three million calls to the underlying random number generator through the rejection strategy. The overall efficiency of the scheme is 0.8% for 32-bit and 0.4% for 64-bit... |
||
<lang parigp>randN(N)=!random(N); |
<lang parigp>randN(N)=!random(N); |
||
unbiased(N)={ |
unbiased(N)={ |