RANDOM() and RANDOM(FALSE) problem



>>>>> "Robert" == Robert Dodier  writes:

    Robert> I found a Lisp implementation of the Mersenne twister.
    Robert> This implementation loads into CMUCL, Clisp, and GCL out 
    Robert> of the box. As you know, CMUCL's RANDOM is a MT 
    Robert> implementation also, but it doesn't drop into Clisp or GCL.

The version in CMUCL is portable and should run anywhere.  The
portable part only generates unsigned 32-bit numbers, though.

A quick looks at jmt.lisp shows why it's 5 times slower than the
equivalent version in CMUCL.  There are lots of function calls in the
generation of a random number.  And the there are things like

           (mod (ash n 15) 2^32)

Since n is an 32-bit number the ash will cons a bignum, only to throw
away the high bits.  (CMUCL's and SBCL's modular arithmetic support
would make this fast if the compiler knew n were a positive 32-bit
number, but it can't assume that.)

The version in CMUCL is carefully written to make sure no bignums are
generated. 

FWIW,

Ray