Post Reply 
RPL and 42S Random Number Generator
11-28-2017, 02:59 AM
Post: #2
RE: RPL and 42S Random Number Generator
For technical reasons, it's nice if a PRNG doesn't generate 0 or 1 exactly. The quick generation of exponential variates, y=-A*Ln(u), and the Box-Muller method for normal variates, r=Sqrt(-2Ln(u1)) and t=2*pi*u2 with x=r*Sin(t) and y=r*Cos(t) for independent pairs of normal, is faster if no tests for 0 or 1 are necessary in inner loops.

For binary computers, I always used the odd multiples of twice the base. For base 10, just odd numbers works with proper scaling.

End cases near 0 or 1 should be sampled with special methods; these are usually covered in papers on rare-event sampling. With a cycle of 10^12, it's rare to get the 0 or 1 (but may crash a program if it happens.)
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: RPL and 42S Random Number Generator - ttw - 11-28-2017 02:59 AM



User(s) browsing this thread: 1 Guest(s)