[SciPy-user] Mersenne Twister PRNG

Robert Kern rkern at ucsd.edu
Sat Sep 3 07:23:30 EDT 2005


I've made a stab at replacing the RANLIB-based PRNG that we currently
use in scipy.stats with the superior-in-every-conceivable-way Mersenne
Twister. It's currently a separate module, and it has only been tested
on Numeric 24.0b2 not the new scipy.base, but it should be able to be
almost a drop-in replacement for the module that's currently there. The
only distribution I haven't covered is the multivariate normal because I
didn't really feel like doing linear algebra in C. But that's easy
enough to do at the Python level.

The core Mersenne Twister routines come from Jean-Sebastien Roy's
RandomKit. Thank you, JS!

  http://www.jeannot.org/~js/code/index.en.html

I would appreciate people putting it through its paces. I've done visual
checking of the distributions via Q-Q plots; the script is included as
the tests/qq.py and requires matplotlib. I haven't implemented real unit
tests via K-S significance tests or Kullback-Leibler distance, but I
guess I ought to eventually. The sampling algorithms were implemented
from scratch by me from the original literature, so if you see funky
numbers, it's probably my fault. AFAICT right now, the numbers are no
funkier than those produced by RANLIB.

  http://cheeseshop.python.org/pypi/mtrand/0.1

-- 
Robert Kern
rkern at ucsd.edu

"In the fields of hell where the grass grows high
 Are the graves of dreams allowed to die."
  -- Richard Harter




More information about the SciPy-User mailing list