MT(3pm) | User Contributed Perl Documentation | MT(3pm) |
Math::Random::MT - The Mersenne Twister PRNG
## Object-oriented interface: use Math::Random::MT; $gen = Math::Random::MT->new() # or... $gen = Math::Random::MT->new($seed); # or... $gen = Math::Random::MT->new(@seeds); $seed = $gen->get_seed(); # seed used to generate the random numbers $rand = $gen->rand(42); # random number in the interval [0, 42) $dice = int($gen->rand(6)+1); # random integer between 1 and 6 $coin = $gen->rand() < 0.5 ? # flip a coin "heads" : "tails" $int = $gen->irand(); # random integer in [0, 2^32-1] ## Function-oriented interface: use Math::Random::MT qw(srand rand irand); # now use srand() and rand() as you usually do in Perl
The Mersenne Twister is a pseudorandom number generator developed by Makoto Matsumoto and Takuji Nishimura. It is described in their paper at <URL:http://www.math.keio.ac.jp/~nisimura/random/doc/mt.ps>. This algorithm has a very uniform distribution and is good for modelling purposes but do not use it for cryptography.
This module implements two interfaces:
<URL:http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html>
Data::Entropy
Abhijit Menon-Sen <ams@toroid.org>
Copyright 2001 Abhijit Menon-Sen. All rights reserved.
Based on the C implementation of MT19937 Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura
This software is distributed under a (three-clause) BSD-style license. See the LICENSE file in the distribution for details.
2022-10-19 | perl v5.36.0 |