next up previous contents
Next: 2.17 Lisp Library Up: 2.16 Random Number Generation Previous: 2.16.1 Original Generator

2.16.2 New Generator

 

In some versions of CMU Common Lisp, the original generator above has been replaced with a subtract-with-borrow generator combined with a Weyl generator.gif The reason for the change was to use a documented generator which has passed tests for randomness.

The subtract-with-borrow generator is described by the following equation
displaymath1209
where z[i] is the i'th random number, which is a double-float. All of the indices in this equation are interpreted modulo 32. The quantity b is carried over from the previous iteration and is either 0 or double-float-epsilon. If z[i] is positive, b is set to zero. Otherwise, b is set to double-float-epsilon.

To increase the randomness of this generator, this generator is combined with a Weyl generator defined by
displaymath1213
where tex2html_wrap_inline17338. Thus, the resulting random number r[i] is
displaymath1216

This generator has been tested by Peter VanEynde usinge Marsaglia's diehard test suite for random number generators; this generator passes the test suite.

This generator is designed for generating floating-point random numbers. To obtain integers, the bits from the significand of the floating-point number are used as the bits of the integer. As many floating-point numbers as needed are generated to obtain the desired number of bits in the random integer.

For floating-point numbers, this generator can by significantly faster than the original generator.



Raymond Toy
Mon Jul 14 09:11:27 EDT 1997