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.) |
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
RPL and 42S Random Number Generator - Thomas Okken - 11-22-2017, 07:16 PM
RE: RPL and 42S Random Number Generator - ttw - 11-28-2017 02:59 AM
RE: RPL and 42S Random Number Generator - toml_12953 - 11-28-2017, 04:32 AM
RE: RPL and 42S Random Number Generator - grsbanks - 11-28-2017, 01:28 PM
RE: RPL and 42S Random Number Generator - Thomas Okken - 11-28-2017, 03:40 PM
|
User(s) browsing this thread: 1 Guest(s)