[Python-Dev] Mersenne Twister

Raymond Hettinger python@rcn.com
Thu, 29 Aug 2002 14:26:59 -0400


I'm sketching out an approach to the Mersenne Twister and 
wanted to make sure it is in line with what you want.

-- Write it in pure python as a drop-in replacement for Wichman-Hill.

-- Add a version number argument to Random() which defaults to two.
    If set to one, use the old generator so that it is possible to recreate
    sequences from earlier versions of Python.  Note, the code is much
    shorter if we drop this requirement.  On the plus side, it gives more
    than backwards compatability, it gives the ability to re-run a
    simulation with another generator to assure that the result isn't
    a fluke related to a generator design flaw.

-- Document David Abrahams's link to 
    http://www.boost.org/boost/random/mersenne_twister.hpp as the
    reference implementation and 
    http://www.math.keio.ac.jp/matumoto/emt.html as a place for
    more information.  Key-off of the MT19337 version as the most
    recent stable evolution.

-- Move the existing in-module test-suite into a unittest.  Add a new,
   separate unittest suite with tests specific to MT (recreating a few 
   sequences produced by reference implementations) and with a battery
   of Knuth style tests.  The validation results are at:  
   http://www.math.keio.ac.jp/matumoto/ver991029.html

-- When we're done, have a python link put on the Mersenne Twister
    Home Page (the second link above).

-- Write, test and document the generator first.  Afterwards, explore
    techniques for creating multiple independent streams:
    http://www.math.h.kyoto-u.ac.jp/~matumoto/RAND/DC/dc.html


Raymond





----- Original Message ----- 
From: "Guido van Rossum" <guido@python.org>
To: "Raymond Hettinger" <python@rcn.com>
Cc: <python-dev@python.org>
Sent: Thursday, August 29, 2002 10:42 AM
Subject: Re: [Python-Dev] Re: A `cogen' module [was: Re: PEP 218 (sets); moving set.py to Lib]


> > > > > FWIW, in case "someone" cares:
> > > > > http://www.boost.org/libs/random/index.html It's a nice
> > > > > library architecture, designed and implemented by people who
> > > > > know the domain, and I think it should be applicable to
> > > > > Python.
> > > >
> > > > I'm willing to implement this one.
> > >
> > > Please do!  (Have you got much experience with random number
> > > generation?)
> > 
> > Yes, but my experience is out-of-date.  I've read Knuth (esp the
> > part on testing generators), done numerical analysis, written
> > simulations and high-end crypto, etc.  The Mersenne Twister
> > algorithm is new to me -- studying it is part of my motivation to
> > volunteer to implement it.
> 
> Cool!  You & Tim will have something to talk about.
> 
> --Guido van Rossum (home page: http://www.python.org/~guido/)