Hi Andreas,
The attached squeak implementation of the TT800 algorithm (related to MT it seems, but with a period of 2^800 instead of 2^19937 -1) was send to the list in 1999, by (the late?) Dave N Smith. Maybe it is of use here?
Hans
-----Original Message----- From: Andreas Raab [mailto:andreas.raab@gmx.de] Sent: woensdag 25 januari 2006 8:00 To: The general-purpose Squeak developers list Subject: Mersenne Twister?
Hi Folks -
Does anyone know a good (Squeak/Smalltalk) implementation of the Mersenne Twister? I have a task for which I don't really trust good ol' Random and would like to use an alternative PRNG instead.
Thanks, - Andreas
This is definitely relevant (I'm mostly looking for something with "large enough" periodicity). Thanks for posting it!
Cheers, - Andreas
Baveco, Hans wrote:
Hi Andreas,
The attached squeak implementation of the TT800 algorithm (related to MT it seems, but with a period of 2^800 instead of 2^19937 -1) was send to the list in 1999, by (the late?) Dave N Smith. Maybe it is of use here?
Hans
-----Original Message----- From: Andreas Raab [mailto:andreas.raab@gmx.de] Sent: woensdag 25 januari 2006 8:00 To: The general-purpose Squeak developers list Subject: Mersenne Twister?
Hi Folks -
Does anyone know a good (Squeak/Smalltalk) implementation of the Mersenne Twister? I have a task for which I don't really trust good ol' Random and would like to use an alternative PRNG instead.
Thanks,
- Andreas
Baveco, Dr. J.M. From: David N. Smith (IBM) [dnsmith@watson.ibm.com] Sent: Thursday, November 04, 1999 9:41 PM To: squeak@cs.uiuc.edu Subject: Re: TT800 (was RE: PRNGs (was [Q] Project: Better performance for LargeIntegers)) At 14:09 -0500 11/2/99, Jeff Szuhay wrote:
At 13:25 -0500 11/2/99, Jeff Szuhay wrote:
...SNIP... and finally,
tt800 source code: http://random.mat.sbg.ac.at/ftp/pub/daa/tt800.c
Jeff:
Can you check this link again? I can get to http://random.mat.sbg.ac.at/ftp/pub but the daa directory is missing and nothing else seems to have a tt800.c file.
Oops...
change .../daa/... to ... /data/... and the page will appear.
OK, I got it and have converted it to Squeak (with some testing assistance from Jeff). The code is attached. It's basically a straight conversion from C. It uses, by its nature, 32-bit long integers and is slow by a factor of about 30 relative to Squeak's Random class.
References and abstracts to the papers are included in the class comment. The original C code (less its tiny main program) is in a method as a comment. There are class methods that test the generator and also assure that it answers the same results as the C version.
This is a good example of why long integers need to be fast, and how easy it is to hit that performance brick wall.
If you are using Random, you can try this by changing the class name to RandomTT800. The #next method answers the next pseudo-random number and #seed: resets the seed. The generator automatically self seeds from the millisecond clock.
Dave
squeak-dev@lists.squeakfoundation.org