An mrg32k3a random-number generator for Common Lisp

mrg32k3a.lisp is a Common Lisp implementation of Pierre L’Ecuyer’s mrg32k3a pseudorandom number generator. See that paper for why this PRNG is great.

Scheme’s SRFI 27 by Sebastian Egner provides what look like truly sophisticated implementations. PLT Scheme uses mrg32k3a for its native PRNG.

mrg32k3a.lisp just encodes the four (!) lines of arithmetic given by L’Ecuyer into simple Lisp, without thought for efficiencies, and gives them the PRNG interface documented in the Common Lisp standard. The package it provides is named mrg32k3a, and its exported symbols are random, *random-state*, make-random-state, and random-state-p.

To make this PRNG a plugin-replacement for your CL’s PRNG, you could load mrg32k3a.lisp, and then do

(shadowing-import '(mrg32k3a:random

Last modified: Thursday, April 9th, 2009 7:36:04pm US/Eastern