<s>
Reservoir	B-Algorithm
sampling	I-Algorithm
is	O
a	O
family	O
of	O
randomized	B-General_Concept
algorithms	I-General_Concept
for	O
choosing	O
a	O
simple	O
random	O
sample	O
,	O
without	O
replacement	O
,	O
of	O
items	O
from	O
a	O
population	O
of	O
unknown	O
size	O
in	O
a	O
single	O
pass	O
over	O
the	O
items	O
.	O
</s>
<s>
A	O
simple	O
reservoir-sampling	O
thus	O
maintains	O
the	O
items	O
with	O
the	O
currently	O
largest	O
associated	O
values	O
in	O
a	O
priority	B-Application
queue	I-Application
.	O
</s>
<s>
The	O
following	O
algorithm	O
was	O
given	O
by	O
Efraimidis	O
and	O
Spirakis	O
that	O
uses	O
interpretation	O
1:This	O
algorithm	O
is	O
identical	O
to	O
the	O
algorithm	O
given	O
in	O
Reservoir	B-Algorithm
Sampling	I-Algorithm
with	O
Random	O
Sort	O
except	O
for	O
the	O
generation	O
of	O
the	O
items	O
 '	O
keys	O
.	O
</s>
<s>
Equivalently	O
,	O
a	O
more	O
numerically	B-Algorithm
stable	I-Algorithm
formulation	O
of	O
this	O
algorithm	O
computes	O
the	O
keys	O
as	O
and	O
select	O
the	O
items	O
with	O
the	O
smallest	O
keys	O
.	O
</s>
<s>
In	O
the	O
general	O
case	O
,	O
the	O
shuffle	O
also	O
needs	O
to	O
work	O
even	O
if	O
the	O
number	O
of	O
cards	O
in	O
the	O
deck	O
is	O
not	O
known	O
in	O
advance	O
,	O
a	O
condition	O
which	O
is	O
satisfied	O
by	O
the	O
inside-out	O
version	O
of	O
the	O
Fisher	B-Algorithm
–	I-Algorithm
Yates	I-Algorithm
shuffle	I-Algorithm
:	O
</s>
<s>
Reservoir	B-Algorithm
sampling	I-Algorithm
makes	O
the	O
assumption	O
that	O
the	O
desired	O
sample	O
fits	O
into	O
main	O
memory	O
,	O
often	O
implying	O
that	O
is	O
a	O
constant	O
independent	O
of	O
.	O
</s>
