<s>
In	O
computing	O
,	O
the	O
alias	B-Algorithm
method	I-Algorithm
is	O
a	O
family	O
of	O
efficient	O
algorithms	O
for	O
sampling	B-Algorithm
from	I-Algorithm
a	I-Algorithm
discrete	I-Algorithm
probability	I-Algorithm
distribution	I-Algorithm
,	O
published	O
in	O
1974	O
by	O
A	O
.	O
J	O
.	O
Walker	O
.	O
</s>
<s>
Internally	O
,	O
the	O
algorithm	O
consults	O
two	O
tables	O
,	O
a	O
probability	O
table	B-Application
and	O
an	O
alias	O
table	B-Application
(	O
for	O
)	O
.	O
</s>
<s>
To	O
generate	O
a	O
random	O
outcome	O
,	O
a	O
fair	O
dice	B-Language
is	O
rolled	O
to	O
determine	O
an	O
index	O
into	O
the	O
two	O
tables	O
.	O
</s>
<s>
An	O
alternative	O
formulation	O
of	O
the	O
probability	O
table	B-Application
,	O
proposed	O
by	O
Marsaglia	O
et	O
al	O
.	O
</s>
<s>
To	O
generate	O
the	O
table	B-Application
,	O
first	O
initialize	O
.	O
</s>
<s>
While	O
doing	O
this	O
,	O
divide	O
the	O
table	B-Application
entries	O
into	O
three	O
categories	O
:	O
</s>
<s>
As	O
long	O
as	O
not	O
all	O
table	B-Application
entries	O
are	O
exactly	O
full	O
,	O
repeat	O
the	O
following	O
steps	O
:	O
</s>
<s>
Each	O
iteration	O
can	O
be	O
done	O
in	O
time	O
,	O
so	O
the	O
table	B-Application
can	O
be	O
set	O
up	O
in	O
time	O
.	O
</s>
<s>
The	O
solution	O
accounting	O
for	O
floating	O
point	O
is	O
sometimes	O
called	O
the	O
Walker-Vose	O
method	O
or	O
the	O
Vose	O
alias	B-Algorithm
method	I-Algorithm
.	O
</s>
<s>
As	O
the	O
lookup	O
procedure	O
is	O
slightly	O
faster	O
if	O
(	O
because	O
does	O
not	O
need	O
to	O
be	O
consulted	O
)	O
,	O
one	O
goal	O
during	O
table	B-Application
generation	O
is	O
to	O
maximize	O
the	O
sum	O
of	O
the	O
.	O
</s>
<s>
Doing	O
this	O
optimally	O
turns	O
out	O
to	O
be	O
NP	O
hard	O
,	O
but	O
a	O
greedy	B-Algorithm
algorithm	I-Algorithm
comes	O
reasonably	O
close	O
:	O
rob	O
from	O
the	O
richest	O
and	O
give	O
to	O
the	O
poorest	O
.	O
</s>
<s>
Although	O
the	O
alias	B-Algorithm
method	I-Algorithm
is	O
very	O
efficient	O
if	O
generating	O
a	O
uniform	O
deviate	O
is	O
itself	O
fast	O
,	O
there	O
are	O
cases	O
where	O
it	O
is	O
far	O
from	O
optimal	O
in	O
terms	O
of	O
random	O
bit	O
usage	O
.	O
</s>
<s>
For	O
example	O
if	O
,	O
then	O
a	O
32-bit	O
random	O
variate	O
could	O
be	O
used	O
to	O
make	O
32	O
choices	O
,	O
but	O
the	O
alias	B-Algorithm
method	I-Algorithm
will	O
only	O
generate	O
one	O
.	O
</s>
<s>
In	O
such	O
cases	O
,	O
the	O
table	B-Application
method	O
described	O
by	O
Marsaglia	O
et	O
al	O
.	O
</s>
<s>
Using	O
arithmetic	B-Algorithm
coding	I-Algorithm
techniques	O
arithmetic	O
we	O
can	O
approach	O
the	O
limit	O
given	O
by	O
the	O
binary	O
entropy	O
function	O
.	O
</s>
<s>
Donald	O
Knuth	O
,	O
The	B-General_Concept
Art	I-General_Concept
of	I-General_Concept
Computer	I-General_Concept
Programming	I-General_Concept
,	O
Vol	O
2	O
:	O
Seminumerical	O
Algorithms	O
,	O
section	O
3.4.1	O
.	O
</s>
