Unbias a random generator: Difference between revisions

Content added Content deleted
(→‎{{header|PARI/GP}}: Incomplete.)
(→‎{{header|PARI/GP}}: !@#@#%$#%^^#$%#$^$%&$@%$^)
Line 245: Line 245:


=={{header|PARI/GP}}==
=={{header|PARI/GP}}==
{{incomplete|PARI/GP|No output shown.}}
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.
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.
<lang parigp>randN(N)=!random(N);
<lang parigp>randN(N)=!random(N);
Line 257: Line 256:
};
};
for(n=3,6,print(n,"\t",sum(k=1,1e5,unbiased(n))))</lang>
for(n=3,6,print(n,"\t",sum(k=1,1e5,unbiased(n))))</lang>

Output:
<pre>3 49913
4 49924
5 50240
6 50277</pre>


=={{header|PicoLisp}}==
=={{header|PicoLisp}}==