<s>
A	O
pseudorandom	B-Algorithm
number	I-Algorithm
generator	I-Algorithm
(	O
PRNG	O
)	O
,	O
also	O
known	O
as	O
a	O
deterministic	O
random	O
bit	O
generator	O
(	O
DRBG	B-Algorithm
)	O
,	O
is	O
an	O
algorithm	O
for	O
generating	O
a	O
sequence	O
of	O
numbers	O
whose	O
properties	O
approximate	O
the	O
properties	O
of	O
sequences	O
of	O
random	O
numbers	O
.	O
</s>
<s>
The	O
PRNG-generated	O
sequence	O
is	O
not	O
truly	O
random	O
,	O
because	O
it	O
is	O
completely	O
determined	O
by	O
an	O
initial	O
value	O
,	O
called	O
the	O
PRNG	O
's	O
seed	B-Algorithm
(	O
which	O
may	O
include	O
truly	O
random	O
values	O
)	O
.	O
</s>
<s>
Although	O
sequences	O
that	O
are	O
closer	O
to	O
truly	O
random	O
can	O
be	O
generated	O
using	O
hardware	O
random	O
number	O
generators	O
,	O
pseudorandom	B-Algorithm
number	I-Algorithm
generators	I-Algorithm
are	O
important	O
in	O
practice	O
for	O
their	O
speed	O
in	O
number	O
generation	O
and	O
their	O
reproducibility	O
.	O
</s>
<s>
for	O
the	O
Monte	B-Algorithm
Carlo	I-Algorithm
method	I-Algorithm
)	O
,	O
electronic	O
games	O
(	O
e.g.	O
</s>
<s>
Cryptographic	O
applications	O
require	O
the	O
output	O
not	O
to	O
be	O
predictable	O
from	O
earlier	O
outputs	O
,	O
and	O
more	O
elaborate	B-Algorithm
algorithms	I-Algorithm
,	O
which	O
do	O
not	O
inherit	O
the	O
linearity	O
of	O
simpler	O
PRNGs	O
,	O
are	O
needed	O
.	O
</s>
<s>
Shorter-than-expected	O
periods	O
for	O
some	O
seed	B-Algorithm
states	O
(	O
such	O
seed	B-Algorithm
states	O
may	O
be	O
called	O
"	O
weak	O
"	O
in	O
this	O
context	O
)	O
;	O
</s>
<s>
An	O
example	O
was	O
the	O
RANDU	B-Algorithm
random	O
number	O
algorithm	O
used	O
for	O
decades	O
on	O
mainframe	B-Architecture
computers	I-Architecture
.	O
</s>
<s>
In	O
many	O
fields	O
,	O
research	O
work	O
prior	O
to	O
the	O
21st	O
century	O
that	O
relied	O
on	O
random	O
selection	O
or	O
on	O
Monte	B-Algorithm
Carlo	I-Algorithm
simulations	I-Algorithm
,	O
or	O
in	O
other	O
ways	O
relied	O
on	O
PRNGs	O
,	O
were	O
much	O
less	O
reliable	O
than	O
ideal	O
as	O
a	O
result	O
of	O
using	O
poor-quality	O
PRNGs	O
.	O
</s>
<s>
As	O
an	O
illustration	O
,	O
consider	O
the	O
widely	O
used	O
programming	O
language	O
Java	B-Language
.	O
</s>
<s>
Up	O
until	O
2020	O
,	O
Java	B-Language
still	O
relied	O
on	O
a	O
linear	B-Algorithm
congruential	I-Algorithm
generator	I-Algorithm
(	O
LCG	B-Algorithm
)	O
for	O
its	O
PRNG	O
,	O
which	O
is	O
of	O
low	O
quality	O
(	O
see	O
further	O
below	O
)	O
.	O
</s>
<s>
Java	B-Language
support	O
was	O
upgraded	O
with	O
Java	B-Language
17	O
.	O
</s>
<s>
One	O
well-known	O
PRNG	O
to	O
avoid	O
major	O
problems	O
and	O
still	O
run	O
fairly	O
quickly	O
is	O
the	O
Mersenne	B-Algorithm
Twister	I-Algorithm
(	O
discussed	O
below	O
)	O
,	O
which	O
was	O
published	O
in	O
1998	O
.	O
</s>
<s>
Other	O
higher-quality	O
PRNGs	O
,	O
both	O
in	O
terms	O
of	O
computational	O
and	O
statistical	O
performance	O
,	O
were	O
developed	O
before	O
and	O
after	O
this	O
date	O
;	O
these	O
can	O
be	O
identified	O
in	O
the	O
List	B-Algorithm
of	I-Algorithm
pseudorandom	I-Algorithm
number	I-Algorithm
generators	I-Algorithm
.	O
</s>
<s>
In	O
the	O
second	O
half	O
of	O
the	O
20th	O
century	O
,	O
the	O
standard	O
class	O
of	O
algorithms	O
used	O
for	O
PRNGs	O
comprised	O
linear	B-Algorithm
congruential	I-Algorithm
generators	I-Algorithm
.	O
</s>
<s>
The	O
quality	O
of	O
LCGs	B-Algorithm
was	O
known	O
to	O
be	O
inadequate	O
,	O
but	O
better	O
methods	O
were	O
unavailable	O
.	O
</s>
<s>
(	O
2007	O
)	O
described	O
the	O
result	O
thus	O
:	O
"	O
If	O
all	O
scientific	O
papers	O
whose	O
results	O
are	O
in	O
doubt	O
because	O
of	O
[	O
LCGs	B-Algorithm
and	O
related ]	O
were	O
to	O
disappear	O
from	O
library	O
shelves	O
,	O
there	O
would	O
be	O
a	O
gap	O
on	O
each	O
shelf	O
about	O
as	O
big	O
as	O
your	O
fist.	O
"	O
</s>
<s>
A	O
major	O
advance	O
in	O
the	O
construction	O
of	O
pseudorandom	B-Error_Name
generators	O
was	O
the	O
introduction	O
of	O
techniques	O
based	O
on	O
linear	O
recurrences	O
on	O
the	O
two-element	O
field	O
;	O
such	O
generators	O
are	O
related	O
to	O
linear-feedback	B-Architecture
shift	I-Architecture
registers	I-Architecture
.	O
</s>
<s>
The	O
1997	O
invention	O
of	O
the	O
Mersenne	B-Algorithm
Twister	I-Algorithm
,	O
in	O
particular	O
,	O
avoided	O
many	O
of	O
the	O
problems	O
with	O
earlier	O
generators	O
.	O
</s>
<s>
The	O
Mersenne	B-Algorithm
Twister	I-Algorithm
has	O
a	O
period	O
of	O
219	O
937−1	O
iterations	O
( ≈	O
4.3	O
)	O
,	O
is	O
proven	O
to	O
be	O
equidistributed	O
in	O
(	O
up	O
to	O
)	O
623	O
dimensions	O
(	O
for	O
32-bit	O
values	O
)	O
,	O
and	O
at	O
the	O
time	O
of	O
its	O
introduction	O
was	O
running	O
faster	O
than	O
other	O
statistically	O
reasonable	O
generators	O
.	O
</s>
<s>
In	O
2003	O
,	O
George	O
Marsaglia	O
introduced	O
the	O
family	O
of	O
xorshift	B-Algorithm
generators	O
,	O
again	O
based	O
on	O
a	O
linear	O
recurrence	O
.	O
</s>
<s>
In	O
2006	O
,	O
the	O
WELL	B-Algorithm
family	O
of	O
generators	O
was	O
developed	O
.	O
</s>
<s>
The	O
WELL	B-Algorithm
generators	O
in	O
some	O
ways	O
improves	O
on	O
the	O
quality	O
of	O
the	O
Mersenne	B-Algorithm
Twister	I-Algorithm
,	O
which	O
has	O
a	O
too-large	O
state	O
space	O
and	O
a	O
very	O
slow	O
recovery	O
from	O
state	O
spaces	O
with	O
a	O
large	O
number	O
of	O
zeros	O
.	O
</s>
<s>
A	O
PRNG	O
suitable	O
for	O
cryptographic	O
applications	O
is	O
called	O
a	O
cryptographically-secure	O
PRNG	O
(	O
CSPRNG	B-Algorithm
)	O
.	O
</s>
<s>
A	O
requirement	O
for	O
a	O
CSPRNG	B-Algorithm
is	O
that	O
an	O
adversary	O
not	O
knowing	O
the	O
seed	B-Algorithm
has	O
only	O
negligible	O
advantage	O
in	O
distinguishing	O
the	O
generator	O
's	O
output	O
sequence	O
from	O
a	O
random	O
sequence	O
.	O
</s>
<s>
In	O
other	O
words	O
,	O
while	O
a	O
PRNG	O
is	O
only	O
required	O
to	O
pass	O
certain	O
statistical	O
tests	O
,	O
a	O
CSPRNG	B-Algorithm
must	O
pass	O
all	O
statistical	O
tests	O
that	O
are	O
restricted	O
to	O
polynomial	O
time	O
in	O
the	O
size	O
of	O
the	O
seed	B-Algorithm
.	O
</s>
<s>
Though	O
a	O
proof	O
of	O
this	O
property	O
is	O
beyond	O
the	O
current	O
state	O
of	O
the	O
art	O
of	O
computational	O
complexity	O
theory	O
,	O
strong	O
evidence	O
may	O
be	O
provided	O
by	O
reducing	B-Algorithm
the	O
CSPRNG	B-Algorithm
to	O
a	O
problem	O
that	O
is	O
assumed	O
to	O
be	O
hard	O
,	O
such	O
as	O
integer	O
factorization	O
.	O
</s>
<s>
In	O
general	O
,	O
years	O
of	O
review	O
may	O
be	O
required	O
before	O
an	O
algorithm	O
can	O
be	O
certified	O
as	O
a	O
CSPRNG	B-Algorithm
.	O
</s>
<s>
Some	O
classes	O
of	O
CSPRNGs	B-Algorithm
include	O
the	O
following	O
:	O
</s>
<s>
It	O
has	O
been	O
shown	O
to	O
be	O
likely	O
that	O
the	O
NSA	O
has	O
inserted	O
an	O
asymmetric	O
backdoor	O
into	O
the	O
NIST-certified	O
pseudorandom	B-Algorithm
number	I-Algorithm
generator	I-Algorithm
Dual_EC_DRBG	O
.	O
</s>
<s>
The	O
simplest	O
examples	O
of	O
this	O
dependency	O
are	O
stream	B-Algorithm
ciphers	I-Algorithm
,	O
which	O
(	O
most	O
often	O
)	O
work	O
by	O
exclusive	O
or-ing	O
the	O
plaintext	O
of	O
a	O
message	O
with	O
the	O
output	O
of	O
a	O
PRNG	O
,	O
producing	O
ciphertext	O
.	O
</s>
<s>
The	O
tests	O
are	O
the	O
monobit	O
test	O
(	O
equal	O
numbers	O
of	O
ones	O
and	O
zeros	O
in	O
the	O
sequence	O
)	O
,	O
poker	O
test	O
(	O
a	O
special	O
instance	O
of	O
the	O
chi-squared	B-General_Concept
test	I-General_Concept
)	O
,	O
runs	O
test	O
(	O
counts	O
the	O
frequency	O
of	O
runs	O
of	O
various	O
lengths	O
)	O
,	O
longruns	O
test	O
(	O
checks	O
whether	O
there	O
exists	O
any	O
run	O
of	O
length	O
34	O
or	O
greater	O
in	O
20	O
000	O
bits	O
of	O
the	O
sequence	O
)	O
—	O
both	O
from	O
BSI	O
and	O
NIST	O
,	O
and	O
the	O
autocorrelation	O
test	O
.	O
</s>
<s>
In	O
essence	O
,	O
these	O
requirements	O
are	O
a	O
test	O
of	O
how	O
well	B-Algorithm
a	O
bit	O
sequence	O
:	O
has	O
zeros	O
and	O
ones	O
equally	O
often	O
;	O
after	O
a	O
sequence	O
of	O
n	O
zeros	O
(	O
or	O
ones	O
)	O
,	O
the	O
next	O
bit	O
a	O
one	O
(	O
or	O
zero	O
)	O
with	O
probability	O
one-half	O
;	O
and	O
any	O
selected	O
subsequence	O
contains	O
no	O
information	O
about	O
the	O
next	O
element(s )	O
in	O
the	O
sequence	O
.	O
</s>
<s>
We	O
call	O
a	O
function	O
(	O
where	O
is	O
the	O
set	O
of	O
positive	O
integers	O
)	O
a	O
pseudo-random	B-Algorithm
number	I-Algorithm
generator	I-Algorithm
for	O
given	O
taking	O
values	O
in	O
if	O
and	O
only	O
if	O
:	O
</s>
<s>
It	O
can	O
be	O
shown	O
that	O
if	O
is	O
a	O
pseudo-random	B-Algorithm
number	I-Algorithm
generator	I-Algorithm
for	O
the	O
uniform	O
distribution	O
on	O
and	O
if	O
is	O
the	O
CDF	O
of	O
some	O
given	O
probability	O
distribution	O
,	O
then	O
is	O
a	O
pseudo-random	B-Algorithm
number	I-Algorithm
generator	I-Algorithm
for	O
,	O
where	O
is	O
the	O
percentile	O
of	O
,	O
i.e.	O
</s>
<s>
An	O
early	O
computer-based	O
PRNG	O
,	O
suggested	O
by	O
John	O
von	O
Neumann	O
in	O
1946	O
,	O
is	O
known	O
as	O
the	O
middle-square	B-Algorithm
method	I-Algorithm
.	O
</s>
<s>
The	O
algorithm	O
is	O
as	O
follows	O
:	O
take	O
any	O
number	O
,	O
square	O
it	O
,	O
remove	O
the	O
middle	O
digits	O
of	O
the	O
resulting	O
number	O
as	O
the	O
"	O
random	O
number	O
"	O
,	O
then	O
use	O
that	O
number	O
as	O
the	O
seed	B-Algorithm
for	O
the	O
next	O
iteration	O
.	O
</s>
<s>
A	O
problem	O
with	O
the	O
"	O
middle	B-Algorithm
square	I-Algorithm
"	O
method	O
is	O
that	O
all	O
sequences	O
eventually	O
repeat	O
themselves	O
,	O
some	O
very	O
quickly	O
,	O
such	O
as	O
"	O
0000	O
"	O
.	O
</s>
<s>
On	O
the	O
ENIAC	B-Device
computer	I-Device
he	O
was	O
using	O
,	O
the	O
"	O
middle	B-Algorithm
square	I-Algorithm
"	O
method	O
generated	O
numbers	O
at	O
a	O
rate	O
some	O
hundred	O
times	O
faster	O
than	O
reading	O
numbers	O
in	O
from	O
punched	B-Architecture
cards	I-Architecture
.	O
</s>
<s>
The	O
middle-square	B-Algorithm
method	I-Algorithm
has	O
since	O
been	O
supplanted	O
by	O
more	O
elaborate	O
generators	O
.	O
</s>
<s>
A	O
recent	O
innovation	O
is	O
to	O
combine	O
the	O
middle	B-Algorithm
square	I-Algorithm
with	O
a	O
Weyl	O
sequence	O
.	O
</s>
<s>
This	O
method	O
produces	O
high-quality	O
output	O
through	O
a	O
long	O
period	O
(	O
see	O
middle-square	B-Algorithm
method	I-Algorithm
)	O
.	O
</s>
<s>
This	O
is	O
based	O
on	O
the	O
inverse	B-Algorithm
transform	I-Algorithm
sampling	I-Algorithm
.	O
</s>
<s>
Repetitive	O
recalculation	O
of	O
should	O
be	O
reduced	O
by	O
means	O
such	O
as	O
ziggurat	B-Algorithm
algorithm	I-Algorithm
for	O
faster	O
generation	O
.	O
</s>
