Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

math::random::mt(3pm) [debian man page]

MT(3pm) 						User Contributed Perl Documentation						   MT(3pm)

NAME
Math::Random::MT - The Mersenne Twister PRNG SYNOPSIS
## 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 DESCRIPTION
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: Object-oriented interface new() Creates a new generator that is automatically seeded based on gettimeofday. new($seed) Creates a new generator seeded with an unsigned 32-bit integer. new(@seeds) Creates a new generator seeded with an array of (up to 624) unsigned 32-bit integers. set_seed() Seeds the generator. It takes the same arguments as new(). get_seed() Retrieves the value of the seed used. rand($num) Behaves exactly like Perl's builtin rand(), returning a number uniformly distributed in [0, $num) ($num defaults to 1). irand() Returns a 32-bit integer, i.e. an integer uniformly distributed in [0, 2^32-1]. Function-oriented interface srand($seed) Behaves just like Perl's builtin srand(). As in Perl >= 5.14, the seed is returned. 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. rand($num) Behaves exactly like Perl's builtin rand(), returning a number uniformly distributed in [0, $num) ($num defaults to 1). irand() Returns a 32-bit integer, i.e. an integer uniformly distributed in [0, 2^32-1]. SEE ALSO
<URL:http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html> Data::Entropy ACKNOWLEDGEMENTS
Sean M. Burke For giving me the idea to write this module. Philip Newton For several useful patches. Florent Angly For implementing seed generation and retrieval. AUTHOR
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. perl v5.14.2 2012-08-07 MT(3pm)

Check Out this Related Man Page

Math::Random::ISAAC::PP(3pm)				User Contributed Perl Documentation			      Math::Random::ISAAC::PP(3pm)

NAME
Math::Random::ISAAC::PP - Pure Perl port of the ISAAC PRNG algorithm VERSION
version 1.003 SYNOPSIS
This module implements the same interface as "Math::Random::ISAAC" and can be used as a drop-in replacement. However, it is recommended that you let the "Math::Random::ISAAC" module decide whether to use the PurePerl or XS version of this module, instead of choosing manually. Selecting the backend to use manually really only has two uses: o If you are trying to avoid the small overhead incurred with dispatching method calls to the appropriate backend modules. o If you are testing the module for performance and wish to explicitly decide which module you would like to use. Example code: # With Math::Random::ISAAC my $rng = Math::Random::ISAAC->new(time); my $rand = $rng->rand(); # With Math::Random::ISAAC::PP my $rng = Math::Random::ISAAC::PP->new(time); my $rand = $rng->rand(); DESCRIPTION
See Math::Random::ISAAC for the full description. METHODS
new Math::Random::ISAAC::PP->new( @seeds ) Implements the interface as specified in "Math::Random::ISAAC" rand $rng->rand() Implements the interface as specified in "Math::Random::ISAAC" irand $rng->irand() Implements the interface as specified in "Math::Random::ISAAC" SEE ALSO
Math::Random::ISAAC BUGS
Please report any bugs or feature requests on the bugtracker website http://rt.cpan.org/NoAuth/Bugs.html?Dist=Math-Random-ISAAC When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature. AUTHOR
Jonathan Yu <jawnsy@cpan.org> COPYRIGHT AND LICENSE
Legally speaking, this package and its contents are: Copyright (c) 2011 by Jonathan Yu <jawnsy@cpan.org>. But this is really just a legal technicality that allows the author to offer this package under the public domain and also a variety of licensing options. For all intents and purposes, this is public domain software, which means you can do whatever you want with it. The software is provided "AS IS", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the software. perl v5.10.1 2011-02-13 Math::Random::ISAAC::PP(3pm)
Man Page