<s>
In	O
data	B-General_Concept
compression	I-General_Concept
,	O
a	O
universal	B-Algorithm
code	I-Algorithm
for	O
integers	O
is	O
a	O
prefix	B-Algorithm
code	I-Algorithm
that	O
maps	O
the	O
positive	O
integers	O
onto	O
binary	O
codewords	O
,	O
with	O
the	O
additional	O
property	O
that	O
whatever	O
the	O
true	O
probability	O
distribution	O
on	O
integers	O
,	O
as	O
long	O
as	O
the	O
distribution	O
is	O
monotonic	O
(	O
i.e.	O
,	O
p(i )	O
≥p( i+1	O
)	O
for	O
all	O
positivei	O
)	O
,	O
the	O
expected	O
lengths	O
of	O
the	O
codewords	O
are	O
within	O
a	O
constant	O
factor	O
of	O
the	O
expected	O
lengths	O
that	O
the	O
optimal	O
code	O
for	O
that	O
probability	O
distribution	O
would	O
have	O
assigned	O
.	O
</s>
<s>
A	O
universal	B-Algorithm
code	I-Algorithm
is	O
asymptotically	O
optimal	O
if	O
the	O
ratio	O
between	O
actual	O
and	O
optimal	O
expected	O
lengths	O
is	O
bounded	O
by	O
a	O
function	O
of	O
the	O
information	O
entropy	O
of	O
the	O
code	O
that	O
,	O
in	O
addition	O
to	O
being	O
bounded	O
,	O
approaches	O
1	O
as	O
entropy	O
approaches	O
infinity	O
.	O
</s>
<s>
In	O
general	O
,	O
most	O
prefix	B-Algorithm
codes	I-Algorithm
for	O
integers	O
assign	O
longer	O
codewords	O
to	O
larger	O
integers	O
.	O
</s>
<s>
Universal	B-Algorithm
codes	I-Algorithm
are	O
generally	O
not	O
used	O
for	O
precisely	O
known	O
probability	O
distributions	O
,	O
and	O
no	O
universal	B-Algorithm
code	I-Algorithm
is	O
known	O
to	O
be	O
optimal	O
for	O
any	O
distribution	O
used	O
in	O
practice	O
.	O
</s>
<s>
A	O
universal	B-Algorithm
code	I-Algorithm
should	O
not	O
be	O
confused	O
with	O
universal	O
source	B-General_Concept
coding	I-General_Concept
,	O
in	O
which	O
the	O
data	B-General_Concept
compression	I-General_Concept
method	O
need	O
not	O
be	O
a	O
fixed	O
prefix	B-Algorithm
code	I-Algorithm
and	O
the	O
ratio	O
between	O
actual	O
and	O
optimal	O
expected	O
lengths	O
must	O
approach	O
one	O
.	O
</s>
<s>
However	O
,	O
note	O
that	O
an	O
asymptotically	O
optimal	O
universal	B-Algorithm
code	I-Algorithm
can	O
be	O
used	O
on	O
independent	O
identically-distributed	O
sources	O
,	O
by	O
using	O
increasingly	O
large	O
blocks	O
,	O
as	O
a	O
method	O
of	O
universal	O
source	B-General_Concept
coding	I-General_Concept
.	O
</s>
<s>
These	O
are	O
some	O
universal	B-Algorithm
codes	I-Algorithm
for	O
integers	O
;	O
an	O
asterisk	B-Language
( *	O
)	O
indicates	O
a	O
code	O
that	O
can	O
be	O
trivially	O
restated	O
in	O
lexicographical	O
order	O
,	O
while	O
a	O
double	O
dagger	O
( ‡	O
)	O
indicates	O
a	O
code	O
that	O
is	O
asymptotically	O
optimal	O
:	O
</s>
<s>
Exp-Golomb	B-Algorithm
coding	I-Algorithm
*	B-Language
,	O
which	O
has	O
Elias	B-Algorithm
gamma	I-Algorithm
coding	I-Algorithm
as	O
a	O
special	O
case	O
.	O
</s>
<s>
Golomb	B-Algorithm
coding	I-Algorithm
,	O
which	O
has	O
Rice	B-Algorithm
coding	I-Algorithm
and	O
unary	B-Algorithm
coding	I-Algorithm
as	O
special	O
cases	O
.	O
</s>
<s>
On	O
the	O
other	O
hand	O
,	O
using	O
the	O
universal	O
Elias	B-Algorithm
gamma	I-Algorithm
coding	I-Algorithm
for	O
the	O
Gauss	O
–	O
Kuzmin	O
distribution	O
results	O
in	O
an	O
expected	O
codeword	O
length	O
(	O
about	O
3.51	O
bits	O
)	O
near	O
entropy	O
(	O
about	O
3.43	O
bits	O
)	O
.	O
</s>
<s>
Huffman	B-General_Concept
coding	I-General_Concept
and	O
arithmetic	B-Algorithm
coding	I-Algorithm
(	O
when	O
they	O
can	O
be	O
used	O
)	O
give	O
at	O
least	O
as	O
good	O
,	O
and	O
often	O
better	O
compression	O
than	O
any	O
universal	B-Algorithm
code	I-Algorithm
.	O
</s>
<s>
However	O
,	O
universal	B-Algorithm
codes	I-Algorithm
are	O
useful	O
when	O
Huffman	B-General_Concept
coding	I-General_Concept
cannot	O
be	O
used	O
—	O
for	O
example	O
,	O
when	O
one	O
does	O
not	O
know	O
the	O
exact	O
probability	O
of	O
each	O
message	O
,	O
but	O
only	O
knows	O
the	O
rankings	O
of	O
their	O
probabilities	O
.	O
</s>
<s>
Universal	B-Algorithm
codes	I-Algorithm
are	O
also	O
useful	O
when	O
Huffman	B-General_Concept
codes	I-General_Concept
are	O
inconvenient	O
.	O
</s>
<s>
For	O
example	O
,	O
when	O
the	O
transmitter	O
but	O
not	O
the	O
receiver	O
knows	O
the	O
probabilities	O
of	O
the	O
messages	O
,	O
Huffman	B-General_Concept
coding	I-General_Concept
requires	O
an	O
overhead	O
of	O
transmitting	O
those	O
probabilities	O
to	O
the	O
receiver	O
.	O
</s>
<s>
Using	O
a	O
universal	B-Algorithm
code	I-Algorithm
does	O
not	O
have	O
that	O
overhead	O
.	O
</s>
<s>
Each	O
universal	B-Algorithm
code	I-Algorithm
,	O
like	O
each	O
other	O
self-delimiting	O
(	O
prefix	O
)	O
binary	O
code	O
,	O
has	O
its	O
own	O
"	O
implied	O
probability	O
distribution	O
"	O
given	O
by	O
where	O
is	O
the	O
length	O
of	O
the	O
ith	O
codeword	O
and	O
P(i )	O
is	O
the	O
corresponding	O
symbol	O
's	O
probability	O
.	O
</s>
<s>
If	O
the	O
actual	O
message	O
probabilities	O
are	O
Q(i )	O
and	O
Kullback	O
–	O
Leibler	O
divergence	O
is	O
minimized	O
by	O
the	O
code	O
with	O
,	O
then	O
the	O
optimal	O
Huffman	B-General_Concept
code	I-General_Concept
for	O
that	O
set	O
of	O
messages	O
will	O
be	O
equivalent	O
to	O
that	O
code	O
.	O
</s>
<s>
Since	O
universal	B-Algorithm
codes	I-Algorithm
are	O
simpler	O
and	O
faster	O
to	O
encode	O
and	O
decode	O
than	O
Huffman	B-General_Concept
codes	I-General_Concept
(	O
which	O
is	O
,	O
in	O
turn	O
,	O
simpler	O
and	O
faster	O
than	O
arithmetic	B-Algorithm
encoding	I-Algorithm
)	O
,	O
the	O
universal	B-Algorithm
code	I-Algorithm
would	O
be	O
preferable	O
in	O
cases	O
where	O
is	O
sufficiently	O
small	O
.	O
</s>
<s>
For	O
any	O
geometric	O
distribution	O
(	O
an	O
exponential	O
distribution	O
on	O
integers	O
)	O
,	O
a	O
Golomb	B-Algorithm
code	I-Algorithm
is	O
optimal	O
.	O
</s>
<s>
With	O
universal	B-Algorithm
codes	I-Algorithm
,	O
the	O
implicit	O
distribution	O
is	O
approximately	O
a	O
power	O
law	O
such	O
as	O
(	O
more	O
precisely	O
,	O
a	O
Zipf	O
distribution	O
)	O
.	O
</s>
<s>
For	O
the	O
ternary	O
comma	B-General_Concept
code	I-General_Concept
(	O
i.e.	O
,	O
encoding	O
in	O
base	O
3	O
,	O
represented	O
with	O
2	O
bits	O
per	O
symbol	O
)	O
,	O
the	O
implicit	O
distribution	O
is	O
a	O
power	O
law	O
with	O
.	O
</s>
