Random Number Generator

I alway forget this algorithm. So here it is for future reference:

A great algorithm by George Marsaglia

  1. Choose a 2-digit number, say 23, your “seed”.
  2. Form a new 2-digit number: the 10’s digit plus 6 times the units digit.
    • 2 + 3 × 6 = 20
  3. The example sequence is 23 → 20 → 02 → 12 → 13 → 19 → 55 → 35 → …
  4. The units digits is your D10.

Good choices for the multiplyer in step 2 are 6, 11, 18.. Do not use 4! If you end up with a three digit number, you treat the first two digits as a single number.

The original post by George Marsaglia

Choose a 2-digit number, say 23, your “seed”. Form a new 2-digit number:
the 10’s digit plus 6 times the units digit.

The example sequence is
23 –> 20 –> 02 –> 12 –> 13 –> 19 –> 55 –> 35 –> …

and its period is the order of the multiplier, 6, in the group of
residues relatively prime to the modulus, 10. (59 in this case).

The “random digits” are the units digits of the 2-digit numbers,
ie, 3,0,2,2,3,9,5,… the sequence mod 10.
The arithmetic is simple enough to carry out in your head.

This is an example of my “multiply-with-carry”
random number generator, and it seems to provide quite satisfactory
sequences mod 2^32 or 2^64 , particularly well suited to
the way that modern CPU’s do integer arithmetic.

You may choose various multipliers and moduli for examples of random
selection of the types you ask about.

A description of the multiply-with-carry method is in the postscript
file mwc1.ps, included in

The Marsaglia Random Number CDROM
with
The DIEHARD Battery of Tests of Randomness,

available at

http://stat.fsu.edu/pub/diehard/

George Marsaglia

#solorpg