<s>
Unary	B-Algorithm
coding	I-Algorithm
,	O
or	O
the	O
unary	O
numeral	O
system	O
and	O
also	O
sometimes	O
called	O
thermometer	B-Algorithm
code	I-Algorithm
,	O
is	O
an	O
entropy	B-Algorithm
encoding	I-Algorithm
that	O
represents	O
a	O
natural	O
number	O
,	O
n	O
,	O
with	O
a	O
code	O
of	O
length	O
n+1	O
(	O
or	O
n	O
)	O
,	O
usually	O
n	O
ones	O
followed	O
by	O
a	O
zero	O
(	O
if	O
natural	O
number	O
is	O
understood	O
as	O
non-negative	O
integer	O
)	O
or	O
with	O
n1	O
ones	O
followed	O
by	O
a	O
zero	O
(	O
if	O
natural	O
number	O
is	O
understood	O
as	O
strictly	O
positive	O
integer	O
)	O
.	O
</s>
<s>
Unary	B-Algorithm
coding	I-Algorithm
is	O
both	O
a	O
prefix-free	B-Algorithm
code	I-Algorithm
and	O
a	O
self-synchronizing	O
code	O
.	O
</s>
<s>
Although	O
it	O
is	O
the	O
optimal	O
symbol-by-symbol	O
coding	O
for	O
such	O
probability	O
distributions	O
,	O
Golomb	B-Algorithm
coding	I-Algorithm
achieves	O
better	O
compression	O
capability	O
for	O
the	O
geometric	O
distribution	O
because	O
it	O
does	O
not	O
consider	O
input	O
symbols	O
independently	O
,	O
but	O
rather	O
implicitly	O
groups	O
the	O
inputs	O
.	O
</s>
<s>
For	O
the	O
same	O
reason	O
,	O
arithmetic	B-Algorithm
encoding	I-Algorithm
performs	O
better	O
for	O
general	O
probability	O
distributions	O
,	O
as	O
in	O
the	O
last	O
case	O
above	O
.	O
</s>
<s>
Examples	O
of	O
unary	B-Algorithm
code	I-Algorithm
uses	O
include	O
:	O
</s>
<s>
In	O
Golomb	B-Algorithm
Rice	I-Algorithm
code	I-Algorithm
,	O
unary	O
encoding	O
is	O
used	O
to	O
encode	O
the	O
quotient	O
part	O
of	O
the	O
Golomb	B-Algorithm
code	I-Algorithm
word	O
.	O
</s>
<s>
Instantaneously	B-Algorithm
trained	I-Algorithm
neural	I-Algorithm
networks	I-Algorithm
use	O
unary	B-Algorithm
coding	I-Algorithm
for	O
efficient	O
data	O
representation	O
.	O
</s>
<s>
Unary	B-Algorithm
coding	I-Algorithm
is	O
used	O
in	O
the	O
neural	B-General_Concept
circuits	I-General_Concept
responsible	O
for	O
birdsong	O
production	O
.	O
</s>
<s>
These	O
codes	O
are	O
guaranteed	O
to	O
end	O
validly	O
on	O
any	O
length	O
of	O
data	O
(	O
when	O
reading	O
arbitrary	O
data	O
)	O
and	O
in	O
the	O
(	O
separate	O
)	O
write	O
cycle	O
allow	O
for	O
the	O
use	O
and	O
transmission	O
of	O
an	O
extra	O
bit	O
(	O
the	O
one	O
used	O
for	O
the	O
first	O
bit	O
)	O
while	O
maintaining	O
overall	O
and	O
per-integer	O
unary	B-Algorithm
code	I-Algorithm
lengths	O
of	O
exactly	O
N	O
.	O
</s>
<s>
n	O
Unary	B-Algorithm
code	I-Algorithm
Alternative	O
1	O
1	O
0	O
2	O
10	O
01	O
3	O
100	O
011	O
4	O
1000	O
0111	O
5	O
10000	O
01111	O
6	O
100000	O
011111	O
7	O
1000000	O
0111111	O
8	O
10000000	O
01111111	O
9	O
100000000	O
011111111	O
10	O
1000000000	O
0111111111	O
...	O
</s>
<s>
Following	O
set	O
of	O
unary	B-Algorithm
codes	I-Algorithm
are	O
symmetric	O
and	O
can	O
be	O
read	O
in	O
any	O
direction	O
.	O
</s>
<s>
n	O
(	O
strictly	O
positive	O
)	O
Unary	B-Algorithm
code	I-Algorithm
Alternativen	O
(	O
non-negative	O
)	O
1	O
1	O
00	O
2	O
00	O
111	O
3	O
010	O
1012	O
4	O
0110	O
10013	O
5	O
01110	O
100014	O
6	O
011110	O
1000015	O
7	O
0111110	O
10000016	O
8	O
01111110	O
100000017	O
9	O
011111110	O
1000000018	O
10	O
0111111110	O
10000000019	O
...	O
</s>
<s>
For	O
unary	O
values	O
where	O
the	O
maximum	O
is	O
known	O
,	O
one	O
can	O
use	O
canonical	O
unary	B-Algorithm
codes	I-Algorithm
that	O
are	O
of	O
a	O
somewhat	O
numerical	O
nature	O
and	O
different	O
from	O
character	O
based	O
codes	O
.	O
</s>
<s>
A	O
generalized	O
version	O
of	O
unary	B-Algorithm
coding	I-Algorithm
was	O
presented	O
by	O
Subhash	O
Kak	O
to	O
represent	O
numbers	O
much	O
more	O
efficiently	O
than	O
standard	O
unary	B-Algorithm
coding	I-Algorithm
.	O
</s>
<s>
Here	O
's	O
an	O
example	O
of	O
generalized	O
unary	B-Algorithm
coding	I-Algorithm
for	O
integers	O
from	O
0	O
through	O
15	O
that	O
requires	O
only	O
7	O
bits	O
(	O
where	O
three	O
bits	O
are	O
arbitrarily	O
chosen	O
in	O
place	O
of	O
a	O
single	O
one	O
in	O
standard	O
unary	O
to	O
show	O
the	O
number	O
)	O
.	O
</s>
<s>
Generalized	O
unary	B-Algorithm
coding	I-Algorithm
requires	O
that	O
the	O
range	O
of	O
numbers	O
to	O
be	O
represented	O
to	O
be	O
pre-specified	O
because	O
this	O
range	O
determines	O
the	O
number	O
of	O
bits	O
that	O
are	O
needed	O
.	O
</s>
