franz lisp (random) bug

Seaman ags at pucc-i
Fri Jun 15 02:03:08 AEST 1984


>  In the 4.2bsd franz (I don't know about others), (random) has the 
>  extremely non-random property of alternating even and odd numbers.

Knuth (Vol. 2, Seminumerical Algorithms) makes the following observations
about random number generators of the linear congruential type:
(m = modulus, w = word size)

1. Using m = w has an enormous advantage in speed, since it avoids the
   need for a divide.

2. When m = w, the right-hand digits of the generated numbers are much less
   random than the left-hand digits (this explains the even-odd behavior).

3. A reasonable alternative is to use m = (w plus or minus 1), which makes
   the right-hand digits more random at the cost of time.

4. "In most applications, the low-order bits are insignificant, and the 
   choice m=w is quite satisfactory -- provided that the programmer using
   the random numbers does so wisely."  (this a direct quote)

The man entry for rand(3) points out that random(3) should be used in
new applications and that rand remains for compatibility.
-- 

Dave Seaman			"My hovercraft is full of eels."
..!pur-ee!pucc-i:ags



More information about the Comp.bugs.4bsd.ucb-fixes mailing list