[Patches] [ python-Patches-658251 ] Mersenne Twister
noreply@sourceforge.net
noreply@sourceforge.net
Sun, 29 Dec 2002 15:09:44 -0800
Patches item #658251, was opened at 2002-12-24 11:45
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=658251&group_id=5470
Category: Modules
Group: Python 2.3
>Status: Closed
>Resolution: Accepted
Priority: 5
Submitted By: Raymond Hettinger (rhettinger)
Assigned to: Nobody/Anonymous (nobody)
Summary: Mersenne Twister
Initial Comment:
Alters random.py to easily accept new core
generators as a superclass. Added a new class
WichmannHill for backwards compatibility and to
serve as a demo of how implement new generators in
pure python.
Adds _random.c to implement the MersenneTwister
generator with a 2**19927-1 period, thread-safety,
and full 53 random bits for each float.
Added test_random.py for non-statistical tests of
random.py. If you have any ideas for moving the
statistical tests, I would love to hear them.
Everything is ready for review and is situated in the
sandbox under the twister directory. It includes a
makefile, setup.py, a news item, docs and is ready to
run directly from the sandbox.
Key design decisions needing review:
* getstate() and setstate() now wrap the same
functions for the core generator so that new
generators can easily be slipped into place without
knowing what is going on in random.py and
random.py's state format can be changed without
touching the underlying generator. This decouples
the two.
* with the new get/set state format, the VERSION
number was bumped to two.
* I couldn't find a direct analog for jumpahead(n) and
that may be a problem with other generators too.
So, I made a weaker implementation that jumps to a
state far away from the current one. This means that
code for the primary use case will still work, but code
that relies on jumping exact n steps forward will
break.
* The old WichmannHill code is kept alive in a
separate subclass. whseed is now only available
through that class and is no longer a module level
attribute.
----------------------------------------------------------------------
>Comment By: Raymond Hettinger (rhettinger)
Date: 2002-12-29 18:09
Message:
Logged In: YES
user_id=80475
GvR accepted by email. Thanks to Just van Rossum for
the initial code review, to Martin v. Löwis for high level
comments, and to Tim Peters for a thorough code review
and numerous edits.
Committed as:
Modules/_randommodule.c 1.1
Lib/random.py 1.41
Lib/test/test_random.py 1.3
Doc/lib/librandom.tex 1.33
Misc/NEWS 1.572
setup.py 1.129
----------------------------------------------------------------------
Comment By: Raymond Hettinger (rhettinger)
Date: 2002-12-26 13:19
Message:
Logged In: YES
user_id=80475
This one is easier to review from the sandbox where all the
files are in one place and ready to run.
Feel free to directly add tests, edit the docs, improve
comments, rename variables and whatnot.
----------------------------------------------------------------------
Comment By: Neal Norwitz (nnorwitz)
Date: 2002-12-26 13:11
Message:
Logged In: YES
user_id=33168
Raymond, was there supposed to be a file attached or are we
to review from the sandbox?
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=658251&group_id=5470