50g: an interesting RAND anomaly
|
03-18-2018, 03:44 AM
Post: #10
|
|||
|
|||
RE: 50g: an interesting RAND anomaly
(03-17-2018 05:02 PM)DavidM Wrote: Consider the following RPL program, which produces a list of 200 pseudo-random integers in the range 0..3: The RNG in question is documented here: https://groups.google.com/forum/m/#!msg/...tzMtZhlGoJ It multiplies the seed by a large prime and takes the redult modulo 1e15, and then cuts off the least significant three digits from that, divides it by 1e15, and returns that. Note there's no additive constant. In multiplying the seed by the prime, the least significant n digits of the seed are completely determined by the least significant n digits of the previous seed, and the least significant n digits of the prime factor. Looking at the least significant 2 bits of the seed-without-its-least-significant-three-digits thus gives a maximum cycle of 4000, and in practice it'll be less because not all of those 4000 values are covered by any combination of starting seed and prime. TL;DR: if you want a random integer between 0 and 3 inclusive, do RAND 4 * IP for maximum cycle length. Stay away from the least significant digits! |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 3 Guest(s)