Sunteți pe pagina 1din 4

In mathematics, a Mersenne prime is a prime number that is one less than a power of two.

That is, it is a prime number that can be written in the form Mn = 2n 1 for some integer n.
They are named after Marin Mersenne, a French Minim friar, who studied them in the early
17th century.
In mathematics, a Mersenne prime is a prime number that is one less than a power of two. That
is, it is a prime number that can be written in the form Mn = 2n 1 for some integer n. They are
named after Marin Mersenne, a French Minim friar, who studied them in the early 17th century.
The first four Mersenne primes (sequence A000668 in OEIS) are 3, 7, 31, and 127.
If n is a composite number then so is 2n 1. (2ab 1 is divisible by both 2a 1 and 2b 1.) The
definition is therefore unchanged when written Mp = 2p 1 where p is assumed prime.
More generally, numbers of the form Mn = 2n 1 without the primality requirement are called
Mersenne numbers. Mersenne numbers are sometimes defined to have the additional
requirement that n be prime, equivalently that they be pernicious Mersenne numbers, namely
those pernicious numbers whose binary representation contains no zeros. The smallest composite
pernicious Mersenne number is 211 1 = 2047 = 23 89.
Mersenne primes Mp are also noteworthy due to their connection to perfect numbers.
As of January 2016, 49 Mersenne primes are known. The largest known prime number 274,207,281
1 is a Mersenne prime.[2][3][4]
Since 1997, all newly found Mersenne primes have been discovered by the Great Internet
Mersenne Prime Search (GIMPS), a distributed computing project on the Internet.

Mersenne Twister
Mersenne Twister is, by far, today's most popular pseudorandom number generator. It is used by
every widely distributed mathematical software package. It has been available as an option in
MATLAB since it was invented and has been the default for almost a decade.
Mersenne Twister was developed by professors Makoto Matsumoto and Takuji Nishimura of
Hiroshima University almost twenty years ago. Here is their home page. The C source code is
available here.
Mersenne primes
Mersenne primes are primes of the form 2^p - 1 where p itself is prime. They are named after a
French friar who studied them in the early 17th century. We learn from Wikipedia that the largest
known prime number is the Mersenne prime with p equal to 57,885,161. The Mersenne Twister
has p equal to 19937. This is tiny as far as Mersenne primes go, but huge as far as random
number generators are concerned.

What is Mersenne Twister (MT)?


Mersenne Twister(MT) is a pseudorandom number generating algorithm developped by Makoto
Matsumoto and Takuji Nishimura (alphabetical order) in 1996/1997. An improvement on
initialization was given on 2002 Jan.
MT has the following merits:

It is designed with consideration on the flaws of various existing generators.

The algorithm is coded into a C-source downloadable below.

Far longer period and far higher order of equidistribution than any other implemented
generators. (It is proved that the period is 2^19937-1, and 623-dimensional
equidistribution property is assured.)

Fast generation. (Although it depends on the system, it is reported that MT is sometimes


faster than the standard ANSI-C library in a system with pipeline and cache memory.)
(Note added in 2004/3: on 1998, usually MT was much faster than rand(), but the
algorithm for rand() has been substituted, and now there are no much difference in
speed.)

Efficient use of the memory. (The implemented C-code mt19937.c consumes only 624
words of working area.)

Why MT? More Reasons


Here we don't want to go into a detailed discussion. For detail, please consult with
the preprint mt.ps. Briefly saying, MT is designed according to the modern
researches on the practical conditions which a generator should satisfy. We don't
have a practical definition of "good pseudorandomness" for pseudorandom number
generators yet now. So, there is no rigourous mathematical assurance for MT to be a
defect-free random number generators.
However, it is widely believed that the spectral test is one of the strongest test to
select a good generator. MT is designed to pass a similar test, called the kdistribution test. For example, if we look the output with 32-bit accuracy, then the
623-tuples from the output in a whole period are equidistributed in the 623dimensional unit cube. For 16-bit accuracy, 1246-tuples are equidistributed in 1246dimension, and for 2-bit accuaracy, in 9968-dimension. These values are at least 15
times larger than the previous records. MT passed many stringent tests, including
the diehard test by G.Marsaglia and the load test by P.Hellekalek and S.Wegenkittl.
MT is an improved version of a very successful generator TT800, which has the
period 2^800-1 and has been used for a few years with favorable comments by
many users. MT is much more robust.
The generator is implemented to generate the output only by fastest arithmetic
operations: no division, no multiplication. By generating an array at one time, it
takes the full advantage of cache memory and pipeline processing.

Some of the comments from researchers(1998)

"This special issue contains articles contributing to these two aspects. In the first article,
Matsumoto and Nishimura propose a class of generators based on linear recurrences
modulo 2. These generators are very fast, have extremely long periods, and appear quite
robust. They provide an implementation in C for a specific instance with period length
2^19937-1. This generator produces 32-bit numbers, and every k-dimensional vector of
such numbers appears the same number of times as k successive values over the period
length, for each k<=623 (except for the zero vector, which appears one time less). If one
looks at only the first n bits of each number, for n <=16, then the property holds for a
larger k, given in Table II of their paper." (From Guest Editorial Introduction of the
forthcoming volume of ACM TOMACS Special Issue on Uniform Random Number
Generation.)

"Thank you for sending me your very interesting paper on the Mersenne Twister. I still
remember your talk on this topic in Montreal which made a big impression there." (Prof.
H.Niederreiter.)

"I would like to study your generators more closely. At the moment, the best generator of
all types of generators I have seen published seems to be TT800, according to our
empirical tests and on the basis of theoretical support." (Prof. P. Hellekalek, 1996. Note
that MT19937 is an improved version of TT800.)

Some of the comments from the users

"MT19937B with my optimizations takes 83% less time than ran2() from Numerical
Recipies, which we had been using. Random number generation was a significant
component of our DSMC application. Switching RNG's therefore reduced execution time
for a 17% reduction in runtime for our full application on a typical problem. Since we
usually run jobs for weeks on supercomputers, this translates directly into real time and
money savings." (From Hawk: Direct Simulation Monte Carlo application for plasma
simulation. Scalable Concurrent Programming Laboratory, Syracuse University.)

"I am a student interested in RNGs for crypto applications. I stumbled upon your
mt19937b PRNG on the web and I am testing it to check whether it's suitable or not to
key generation. Previously I tried other PRNGs but unfortunately they weren't good
enough, mainly because (I guess) of short cycles. The problems arise when you try to
periodically reseed the PRNG: even if you start the key-generation process with a
different seed every time, sooner or later you'll have the PRNG falling into an alreadypassed state eventually obtaining the same key as before... Are the short cycles to blame?.
Anyway this didn't happen so far with your mt19937b generator and I would be glad to
know the reason of this improvement, namely: are you sure that reseeding your PRNG
with *different* seeds (32 bit) I'll get a totally different output stream every time?"
Answer: the probability to get an overlapping sequences is very very very small,
negligiblly small.

"I've been seeing good results from your mt19937b RNG in the simulation of a small
multi-agent system for which many other generators have been giving poor to marginal
results. The RNG is being used to help verify probabilistic calculations for this multiagent system which give an accurate reference for comparison. Some initially worrying
discrepancies disappeared when using mt19937b, so I'm quite grateful for you
contribution. My work uses the CMU Common Lisp language and your algorithm has
been implemented in lisp. A small change was made to the implementation of the
tempering calculations to avoid overflowing 32bit numbers (the algorithm is unchanged).
To further enhance performance an Intel x86 specific version has also been written,
which runs about 33% faster than optimised C.
...
I'm currently helping to maintain CMUCL and since mt19937b seems to be performing
well (and is faster) I was wondering if you would recommend and give permission to use
mt19937b as the basis of a revised RNG for CMUCL which is distributed as public
domain code?"

S-ar putea să vă placă și