<s>
The	O
Mersenne	B-Algorithm
Twister	I-Algorithm
is	O
a	O
general-purpose	O
pseudorandom	B-Algorithm
number	I-Algorithm
generator	I-Algorithm
(	O
PRNG	O
)	O
developed	O
in	O
1997	O
by	O
and	O
.	O
</s>
<s>
The	O
Mersenne	B-Algorithm
Twister	I-Algorithm
was	O
designed	O
specifically	O
to	O
rectify	O
most	O
of	O
the	O
flaws	O
found	O
in	O
older	O
PRNGs	O
.	O
</s>
<s>
The	O
most	O
commonly	O
used	O
version	O
of	O
the	O
Mersenne	B-Algorithm
Twister	I-Algorithm
algorithm	O
is	O
based	O
on	O
the	O
Mersenne	O
prime	O
.	O
</s>
<s>
The	O
standard	O
implementation	O
of	O
that	O
,	O
MT19937	B-Algorithm
,	O
uses	O
a	O
32-bit	O
word	O
length	O
.	O
</s>
<s>
There	O
is	O
another	O
implementation	O
(	O
with	O
five	O
variants	O
)	O
that	O
uses	O
a	O
64-bit	O
word	O
length	O
,	O
MT19937-64	O
;	O
it	O
generates	O
a	O
different	O
sequence	O
.	O
</s>
<s>
The	O
Mersenne	B-Algorithm
Twister	I-Algorithm
is	O
used	O
as	O
default	O
PRNG	O
by	O
the	O
following	O
software	O
:	O
</s>
<s>
It	O
is	O
also	O
available	O
in	O
Apache	B-Language
Commons	I-Language
,	O
in	O
the	O
standard	O
C++	B-Language
library	O
(	O
since	O
C++11	B-Language
)	O
,	O
and	O
in	O
Mathematica	B-Language
.	O
</s>
<s>
Add-on	O
implementations	O
are	O
provided	O
in	O
many	O
program	O
libraries	O
,	O
including	O
the	O
Boost	B-Language
C++	I-Language
Libraries	I-Language
,	O
the	O
CUDA	B-Architecture
Library	I-Architecture
,	O
and	O
the	O
NAG	O
Numerical	O
Library	O
.	O
</s>
<s>
The	O
Mersenne	B-Algorithm
Twister	I-Algorithm
is	O
one	O
of	O
two	O
PRNGs	O
in	O
SPSS	B-Algorithm
:	O
the	O
other	O
generator	O
is	O
kept	O
only	O
for	O
compatibility	O
with	O
older	O
programs	O
,	O
and	O
the	O
Mersenne	B-Algorithm
Twister	I-Algorithm
is	O
stated	O
to	O
be	O
"	O
more	O
reliable	O
"	O
.	O
</s>
<s>
The	O
Mersenne	B-Algorithm
Twister	I-Algorithm
is	O
similarly	O
one	O
of	O
the	O
PRNGs	O
in	O
SAS	B-Language
:	O
the	O
other	O
generators	O
are	O
older	O
and	O
deprecated	O
.	O
</s>
<s>
The	O
Mersenne	B-Algorithm
Twister	I-Algorithm
is	O
the	O
default	O
PRNG	O
in	O
Stata	B-Algorithm
,	O
the	O
other	O
one	O
is	O
KISS	B-Algorithm
,	O
for	O
compatibility	O
with	O
older	O
versions	O
of	O
Stata	B-Algorithm
.	O
</s>
<s>
Permissively-licensed	B-License
and	O
patent-free	O
for	O
all	O
variants	O
except	O
CryptMT	B-Algorithm
.	O
</s>
<s>
Passes	O
numerous	O
tests	O
for	O
statistical	O
randomness	O
,	O
including	O
the	O
Diehard	O
tests	O
and	O
most	O
,	O
but	O
not	O
all	O
of	O
the	O
TestU01	B-Algorithm
tests	O
.	O
</s>
<s>
A	O
study	O
found	O
that	O
the	O
Mersenne	B-Algorithm
Twister	I-Algorithm
creates	O
64-bit	O
floating	O
point	O
random	O
numbers	O
approximately	O
twenty	O
times	O
faster	O
than	O
the	O
hardware-implemented	O
,	O
processor-based	O
RDRAND	B-Language
instruction	O
set	O
.	O
</s>
<s>
Exhibits	O
two	O
clear	O
failures	O
(	O
linear	O
complexity	O
)	O
in	O
both	O
Crush	O
and	O
BigCrush	O
in	O
the	O
TestU01	B-Algorithm
suite	O
.	O
</s>
<s>
The	O
test	O
,	O
like	O
Mersenne	B-Algorithm
Twister	I-Algorithm
,	O
is	O
based	O
on	O
an	O
-algebra	O
.	O
</s>
<s>
Multiple	O
instances	O
that	O
differ	O
only	O
in	O
seed	O
value	O
(	O
but	O
not	O
other	O
parameters	O
)	O
are	O
not	O
generally	O
appropriate	O
for	O
Monte-Carlo	B-Algorithm
simulations	I-Algorithm
that	O
require	O
independent	O
random	O
number	O
generators	O
,	O
though	O
there	O
exists	O
a	O
method	O
for	O
choosing	O
multiple	O
sets	O
of	O
parameter	O
values	O
.	O
</s>
<s>
The	O
GPU	B-Architecture
version	O
(	O
MTGP	O
)	O
is	O
said	O
to	O
be	O
even	O
better	O
.	O
</s>
<s>
Is	O
not	O
cryptographically	B-Algorithm
secure	I-Algorithm
,	O
unless	O
the	O
CryptMT	B-Algorithm
variant	O
(	O
discussed	O
below	O
)	O
is	O
used	O
.	O
</s>
<s>
The	O
reason	O
is	O
that	O
observing	O
a	O
sufficient	O
number	O
of	O
iterations	O
(	O
624	O
in	O
the	O
case	O
of	O
MT19937	B-Algorithm
,	O
since	O
this	O
is	O
the	O
size	O
of	O
the	O
state	O
vector	O
from	O
which	O
future	O
iterations	O
are	O
produced	O
)	O
allows	O
one	O
to	O
predict	O
all	O
future	O
iterations	O
.	O
</s>
<s>
An	O
alternative	O
generator	O
,	O
WELL	B-Algorithm
(	O
"	O
Well	B-Algorithm
Equidistributed	I-Algorithm
Long-period	I-Algorithm
Linear	I-Algorithm
"	O
)	O
,	O
offers	O
quicker	O
recovery	O
,	O
and	O
equal	O
randomness	O
,	O
and	O
nearly	O
equal	O
speed	O
.	O
</s>
<s>
Marsaglia	O
's	O
xorshift	B-Algorithm
generators	O
and	O
variants	O
are	O
the	O
fastest	O
in	O
the	O
class	O
of	O
LFSRs	B-Architecture
.	O
</s>
<s>
64-bit	O
MELGs	O
(	O
"	O
64-bit	O
Maximally	O
Equidistributed	O
-Linear	O
Generators	O
with	O
Mersenne	O
Prime	O
Period	O
"	O
)	O
are	O
completely	O
optimized	O
in	O
terms	O
of	O
the	O
k-distribution	B-Algorithm
properties	O
.	O
</s>
<s>
The	O
ACORN	B-Algorithm
family	I-Algorithm
(	O
published	O
1989	O
)	O
is	O
another	O
k-distributed	O
PRNG	O
,	O
which	O
shows	O
similar	O
computational	O
speed	O
to	O
MT	O
,	O
and	O
better	O
statistical	O
properties	O
as	O
it	O
satisfies	O
all	O
the	O
current	O
(	O
2019	O
)	O
TestU01	B-Algorithm
criteria	O
;	O
when	O
used	O
with	O
appropriate	O
choices	O
of	O
parameters	O
,	O
ACORN	B-Algorithm
can	O
have	O
arbitrarily	O
long	O
period	O
and	O
precision	O
.	O
</s>
<s>
The	O
PCG	B-Algorithm
family	I-Algorithm
is	O
a	O
more	O
modern	O
long-period	O
generator	O
,	O
with	O
better	O
cache	O
locality	O
,	O
and	O
less	O
detectable	O
bias	O
using	O
modern	O
analysis	O
methods	O
.	O
</s>
<s>
A	O
pseudorandom	B-Algorithm
sequence	I-Algorithm
of	O
w-bit	O
integers	O
of	O
period	O
P	O
is	O
said	O
to	O
be	O
k-distributed	O
to	O
v-bit	O
accuracy	O
if	O
the	O
following	O
holds	O
.	O
</s>
<s>
For	O
a	O
w-bit	O
word	O
length	O
,	O
the	O
Mersenne	B-Algorithm
Twister	I-Algorithm
generates	O
integers	O
in	O
the	O
range	O
.	O
</s>
<s>
The	O
Mersenne	B-Algorithm
Twister	I-Algorithm
algorithm	O
is	O
based	O
on	O
a	O
matrix	O
linear	O
recurrence	O
over	O
a	O
finite	O
binary	O
field	O
.	O
</s>
<s>
The	O
algorithm	O
is	O
a	O
twisted	O
generalised	B-Architecture
feedback	I-Architecture
shift	I-Architecture
register	I-Architecture
(	O
twisted	O
GFSR	B-Architecture
,	O
or	O
TGFSR	O
)	O
of	O
rational	O
normal	O
form	O
(TGFSR(R )	O
)	O
,	O
with	O
state	O
bit	O
reflection	O
and	O
tempering	O
.	O
</s>
<s>
r	B-Language
:	O
separation	O
point	O
of	O
one	O
word	O
,	O
or	O
the	O
number	O
of	O
bits	O
of	O
the	O
lower	O
bitmask	O
,	O
</s>
<s>
This	O
choice	O
simplifies	O
the	O
primitivity	O
test	O
and	O
k-distribution	B-Algorithm
test	O
that	O
are	O
needed	O
in	O
the	O
parameter	O
search	O
.	O
</s>
<s>
where	O
denotes	O
concatenation	O
of	O
bit	O
vectors	O
(	O
with	O
upper	O
bits	O
on	O
the	O
left	O
)	O
,	O
the	O
bitwise	O
exclusive	O
or	O
(	O
XOR	O
)	O
,	O
means	O
the	O
upper	O
bits	O
of	O
,	O
and	O
means	O
the	O
lower	O
r	B-Language
bits	O
of	O
.	O
</s>
<s>
As	O
like	O
TGFSR(R )	O
,	O
the	O
Mersenne	B-Algorithm
Twister	I-Algorithm
is	O
cascaded	O
with	O
a	O
tempering	O
transform	O
to	O
compensate	O
for	O
the	O
reduced	O
dimensionality	O
of	O
equidistribution	O
(	O
because	O
of	O
the	O
choice	O
of	O
A	O
being	O
in	O
the	O
rational	O
normal	O
form	O
)	O
.	O
</s>
<s>
The	O
coefficients	O
for	O
MT19937	B-Algorithm
are	O
:	O
</s>
<s>
Note	O
that	O
32-bit	O
implementations	O
of	O
the	O
Mersenne	B-Algorithm
Twister	I-Algorithm
generally	O
have	O
d	O
=	O
FFFFFFFF16	O
.	O
</s>
<s>
The	O
coefficients	O
for	O
MT19937-64	O
are	O
:	O
</s>
<s>
The	O
state	O
needed	O
for	O
a	O
Mersenne	B-Algorithm
Twister	I-Algorithm
implementation	O
is	O
an	O
array	O
of	O
n	O
values	O
of	O
w	O
bits	O
each	O
.	O
</s>
<s>
The	O
value	O
for	O
f	O
for	O
MT19937	B-Algorithm
is	O
1812433253	O
.	O
</s>
<s>
The	O
value	O
for	O
f	O
for	O
MT19937-64	O
is	O
6364136223846793005	O
.	O
</s>
<s>
The	O
twist	O
transformation	O
improves	O
the	O
classical	O
GFSR	B-Architecture
with	O
the	O
following	O
key	O
properties	O
:	O
</s>
<s>
The	O
following	O
pseudocode	O
implements	O
the	O
general	O
Mersenne	B-Algorithm
Twister	I-Algorithm
algorithm	O
.	O
</s>
<s>
The	O
constants	O
w	O
,	O
n	O
,	O
m	O
,	O
r	B-Language
,	O
a	O
,	O
u	O
,	O
d	O
,	O
s	O
,	O
b	O
,	O
t	O
,	O
c	O
,	O
l	O
,	O
and	O
f	O
are	O
as	O
in	O
the	O
algorithm	O
description	O
above	O
.	O
</s>
<s>
CryptMT	B-Algorithm
is	O
a	O
stream	B-Algorithm
cipher	I-Algorithm
and	O
cryptographically	B-Algorithm
secure	I-Algorithm
pseudorandom	I-Algorithm
number	I-Algorithm
generator	I-Algorithm
which	O
uses	O
Mersenne	B-Algorithm
Twister	I-Algorithm
internally	O
.	O
</s>
<s>
Unlike	O
Mersenne	B-Algorithm
Twister	I-Algorithm
or	O
its	O
other	O
derivatives	O
,	O
CryptMT	B-Algorithm
is	O
patented	O
.	O
</s>
<s>
MTGP	O
is	O
a	O
variant	O
of	O
Mersenne	B-Algorithm
Twister	I-Algorithm
optimised	O
for	O
graphics	B-Architecture
processing	I-Architecture
units	I-Architecture
published	O
by	O
Mutsuo	O
Saito	O
and	O
Makoto	O
Matsumoto	O
.	O
</s>
<s>
The	O
paper	O
claims	O
improved	O
equidistribution	O
over	O
MT	O
and	O
performance	O
on	O
a	O
very	O
old	O
GPU	B-Architecture
(	O
Nvidia	O
GTX260	O
with	O
192	O
cores	O
)	O
of	O
4.7ms	O
for	O
5×107	O
random	O
32-bit	O
integers	O
.	O
</s>
<s>
The	O
SFMT	O
(	O
SIMD-oriented	O
Fast	O
Mersenne	B-Algorithm
Twister	I-Algorithm
)	O
is	O
a	O
variant	O
of	O
Mersenne	B-Algorithm
Twister	I-Algorithm
,	O
introduced	O
in	O
2006	O
,	O
designed	O
to	O
be	O
fast	O
when	O
it	O
runs	O
on	O
128-bit	O
SIMD	B-Device
.	O
</s>
<s>
It	O
is	O
roughly	O
twice	O
as	O
fast	O
as	O
Mersenne	B-Algorithm
Twister	I-Algorithm
.	O
</s>
<s>
It	O
has	O
a	O
better	O
equidistribution	O
property	O
of	O
v-bit	O
accuracy	O
than	O
MT	O
but	O
worse	O
than	O
WELL	B-Algorithm
(	O
"	O
Well	B-Algorithm
Equidistributed	I-Algorithm
Long-period	I-Algorithm
Linear	I-Algorithm
"	O
)	O
.	O
</s>
<s>
It	O
has	O
quicker	O
recovery	O
from	O
zero-excess	O
initial	O
state	O
than	O
MT	O
,	O
but	O
slower	O
than	O
WELL	B-Algorithm
.	O
</s>
<s>
Intel	O
SSE2	B-General_Concept
and	O
PowerPC	B-Architecture
AltiVec	O
are	O
supported	O
by	O
SFMT	O
.	O
</s>
<s>
It	O
is	O
also	O
used	O
for	O
games	O
with	O
the	O
Cell	B-General_Concept
BE	I-General_Concept
in	O
the	O
PlayStation	B-Operating_System
3	I-Operating_System
.	O
</s>
<s>
TinyMT	O
is	O
a	O
variant	O
of	O
Mersenne	B-Algorithm
Twister	I-Algorithm
,	O
proposed	O
by	O
Saito	O
and	O
Matsumoto	O
in	O
2011	O
.	O
</s>
