This is a package that provides alternative pseudo-random number generators.

**mt_rand()** is 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.

**isaac_rand()** uses the ISAAC algorithm [L3 ] by Bob Jenkins. ISAAC (Indirection, Shift, Accumulate, Add, and Count) generates 32-bit random numbers. The period is guaranteed to be at least 2**40 and is 2**8295 on average. The results are uniformly distributed, unbiased, and unpredictable unless you know the seed. This PRNG **is** suitable for cryptographic use provided a suitably random seed can be provided.

Currently the code is available at

cvs -d:pserver:[email protected]:/cvsroot/tclsoap co Random

and the distributable files are at http://sourceforge.net/projects/tclsoap in the downloads section.

**Usage**

# Seed and use the Mersenne Twister PRNG % expr {mt_srand(0)} 0.548813502432 % expr {mt_rand()} 0.592844616527 # Seed and use the ISAAC PRNG % expr {isaac_srand(0)} 0.0943298905842 % expr {isaac_rand()} 0.187672290296 # Extended ISAAC commands # Provide extra seed data (up to 256 values can be used) % ::isaac::isaac seed "\x01\x02\x03\x04\x05" # Get integers from the PRNG (must have been seeded already) % ::isaac::isaac integer 1439929434 # Get doubles (equivalent to the expr function) % ::isaac::isaac double 0.960589176966