NAME

Math::Random::MT::Perl - Pure Perl Pseudorandom Number Generator

SYNOPSIS

use Math::Random::MT::Perl;

$gen = Math::Random::MT::Perl->new($seed);
print $gen->rand(3);

OR

use Math::Random::MT qw(srand rand);

# now srand and rand behave as usual.

DESCRIPTION

Pure Perl implementation of the Mersenne Twister algorithm as implemented in Math::Random::MT. The Mersenne Twister is a pseudorandom number generator developed by Makoto Matsumoto and Takuji Nishimura.

This module implements two interfaces, as described in the synopsis above. It defines the following functions.

Functions

new($seed)

Creates a new generator seeded with an unsigned 32-bit integer.

rand($num)

Can be called via the OO in interface or exported. Behaves exactly like Perl's builtin rand(), returning a number uniformly distributed in [0, $num) ($num defaults to 1) except the underlying complexity is 32 bits rather than some small fraction of this.

srand($seed)

Behaves just like Perl's builtin srand(). If you use this interface, it is strongly recommended that you call srand() explicitly, rather than relying on rand() to call it the first time it is used. Has no effect if called via OO interface - pass the seed to new.

EXPORT

None by default. rand() and srand() on demand.

SEE ALSO

Math::Random::MT

<URL:http://www.math.keio.ac.jp/~matumoto/emt.html>

AUTHOR

Dr James Freeman <airmedical@gmail.com>

COPYRIGHT AND LICENSE

Copyright (C) 2008 by Dr James Freeman

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.