See random for the newer version.
This is a package that provides an alternative pseudo-random number generator based upon the Mersenne Twister PRNG algorithm ([L1 ], [L2 ]). This PRNG has an enormous period (in fact it is 2**19937-1 which is a Mersenne Prime, hence the name). It is also suposedly faster than the standard C library rand() function. Furthermore, while the stock Tcl rand function generates numbers in the range (0,1) - randmt produces numbers in the range [0,1]. If required, it can also produce values within (0,1) as well as integer values (any 32bit value) - we would just need some names for these functions.
Currently the code is available at
cvs -d:pserver:[email protected]:/cvsroot/tclsoap co RandMT
and the distributable files are at http://sourceforge.net/projects/tclsoap in the downloads section.
EKB This might be a good candidate for the Tcl core as an additional math function ::tcl::math::randmt, since it is a compiled extension. The existing rand could be renamed ::tcl::math::randlc (for linear congruential generator), and then rand could be defined as one of these, either as a proc or using rename:
rename ::tcl::math::randmt ::tcl::math::rand
That way, any existing code could use either random number generator (or other future alternatives).
Does this sound interesting to people? If it does, I could draft a TIP.