[prev] 108 [next]

Sidetrack: Random Numbers (cont)

It is a complex task to pick good numbers. A bit of history:

Lewis, Goodman and Miller (1969) suggested

  • Xn+1 = 75·Xn mod (231-1)
  • note:
    • 75 is 16807
    • 231-1 is 2147483647
    • X0 = 0 is not a good seed value

Most compilers use LCG-based algorithms that are slightly more involved; see www.mscs.dal.ca/~selinger/random/ for details (including a short C program that produces the exact same pseudo-random numbers as gcc for any given seed value)