<s>
Golomb	B-Algorithm
coding	I-Algorithm
is	O
a	O
lossless	B-Algorithm
data	I-Algorithm
compression	I-Algorithm
method	O
using	O
a	O
family	O
of	O
data	B-General_Concept
compression	I-General_Concept
codes	O
invented	O
by	O
Solomon	O
W	O
.	O
Golomb	O
in	O
the	O
1960s	O
.	O
</s>
<s>
Alphabets	O
following	O
a	O
geometric	O
distribution	O
will	O
have	O
a	O
Golomb	B-Algorithm
code	I-Algorithm
as	O
an	O
optimal	O
prefix	B-Algorithm
code	I-Algorithm
,	O
making	O
Golomb	B-Algorithm
coding	I-Algorithm
highly	O
suitable	O
for	O
situations	O
in	O
which	O
the	O
occurrence	O
of	O
small	O
values	O
in	O
the	O
input	O
stream	O
is	O
significantly	O
more	O
likely	O
than	O
large	O
values	O
.	O
</s>
<s>
Rice	O
coding	O
(	O
invented	O
by	O
Robert	O
F	O
.	O
Rice	O
)	O
denotes	O
using	O
a	O
subset	O
of	O
the	O
family	O
of	O
Golomb	B-Algorithm
codes	I-Algorithm
to	O
produce	O
a	O
simpler	O
(	O
but	O
possibly	O
suboptimal	O
)	O
prefix	B-Algorithm
code	I-Algorithm
.	O
</s>
<s>
Rice	O
used	O
this	O
set	O
of	O
codes	O
in	O
an	O
adaptive	B-Algorithm
coding	I-Algorithm
scheme	O
;	O
"	O
Rice	O
coding	O
"	O
can	O
refer	O
either	O
to	O
that	O
adaptive	O
scheme	O
or	O
to	O
using	O
that	O
subset	O
of	O
Golomb	B-Algorithm
codes	I-Algorithm
.	O
</s>
<s>
Whereas	O
a	O
Golomb	B-Algorithm
code	I-Algorithm
has	O
a	O
tunable	O
parameter	O
that	O
can	O
be	O
any	O
positive	O
integer	O
value	O
,	O
Rice	O
codes	O
are	O
those	O
in	O
which	O
the	O
tunable	O
parameter	O
is	O
a	O
power	O
of	O
two	O
.	O
</s>
<s>
Rice	O
coding	O
is	O
used	O
as	O
the	O
entropy	B-Algorithm
encoding	I-Algorithm
stage	O
in	O
a	O
number	O
of	O
lossless	B-Algorithm
image	B-General_Concept
compression	I-General_Concept
and	O
audio	O
data	B-General_Concept
compression	I-General_Concept
methods	O
.	O
</s>
<s>
Golomb	B-Algorithm
coding	I-Algorithm
uses	O
a	O
tunable	O
parameter	O
to	O
divide	O
an	O
input	O
value	O
into	O
two	O
parts	O
:	O
,	O
the	O
result	O
of	O
a	O
division	O
by	O
,	O
and	O
,	O
the	O
remainder	O
.	O
</s>
<s>
The	O
quotient	O
is	O
sent	O
in	O
unary	B-Algorithm
coding	I-Algorithm
,	O
followed	O
by	O
the	O
remainder	O
in	O
truncated	B-Algorithm
binary	I-Algorithm
encoding	I-Algorithm
.	O
</s>
<s>
When	O
,	O
Golomb	B-Algorithm
coding	I-Algorithm
is	O
equivalent	O
to	O
unary	B-Algorithm
coding	I-Algorithm
.	O
</s>
<s>
Both	O
and	O
will	O
be	O
encoded	O
using	O
variable	O
numbers	O
of	O
bits	O
:	O
by	O
a	O
unary	B-Algorithm
code	I-Algorithm
,	O
and	O
by	O
bits	O
for	O
Rice	O
code	O
,	O
or	O
a	O
choice	O
between	O
and	O
bits	O
for	O
Golomb	B-Algorithm
code	I-Algorithm
(	O
i.e.	O
</s>
<s>
The	O
Golomb	B-Algorithm
code	I-Algorithm
for	O
this	O
distribution	O
is	O
equivalent	O
to	O
the	O
Huffman	B-General_Concept
code	I-General_Concept
for	O
the	O
same	O
probabilities	O
,	O
if	O
it	O
were	O
possible	O
to	O
compute	O
the	O
Huffman	B-General_Concept
code	I-General_Concept
for	O
the	O
infinite	O
set	O
of	O
source	O
values	O
.	O
</s>
<s>
Truly	O
optimal	O
codes	O
for	O
two-sided	O
geometric	O
distributions	O
include	O
multiple	O
variants	O
of	O
the	O
Golomb	B-Algorithm
code	I-Algorithm
,	O
depending	O
on	O
the	O
distribution	O
parameters	O
,	O
including	O
this	O
one	O
.	O
</s>
<s>
Below	O
is	O
the	O
Rice	O
–	O
Golomb	O
encoding	O
,	O
where	O
the	O
remainder	O
code	O
uses	O
simple	O
truncated	B-Algorithm
binary	I-Algorithm
encoding	I-Algorithm
,	O
also	O
named	O
"	O
Rice	O
coding	O
"	O
(	O
other	O
varying-length	O
binary	O
encodings	O
,	O
like	O
arithmetic	O
or	O
Huffman	B-General_Concept
encodings	I-General_Concept
,	O
are	O
possible	O
for	O
the	O
remainder	O
codes	O
,	O
if	O
the	O
statistic	O
distribution	O
of	O
remainder	O
codes	O
is	O
not	O
flat	O
,	O
and	O
notably	O
when	O
not	O
all	O
possible	O
remainders	O
after	O
the	O
division	O
are	O
used	O
)	O
.	O
</s>
<s>
Use	O
for	O
run-length	O
encoding	O
Note	O
that	O
and	O
are	O
reversed	O
in	O
this	O
section	O
compared	O
to	O
the	O
use	O
in	O
earlier	O
sections.Given	O
an	O
alphabet	O
of	O
two	O
symbols	O
,	O
or	O
a	O
set	O
of	O
two	O
events	O
,	O
P	O
and	O
Q	O
,	O
with	O
probabilities	O
p	O
and	O
(	O
)	O
respectively	O
,	O
where	O
,	O
Golomb	B-Algorithm
coding	I-Algorithm
can	O
be	O
used	O
to	O
encode	O
runs	O
of	O
zero	O
or	O
more	O
P	O
′s	O
separated	O
by	O
single	O
Q	O
′s	O
.	O
</s>
<s>
When	O
p	O
=	O
1/2	O
,	O
M	O
=	O
1	O
,	O
and	O
the	O
Golomb	B-Algorithm
code	I-Algorithm
corresponds	O
to	O
unary	O
(	O
P	O
′s	O
followed	O
by	O
a	O
Q	O
is	O
encoded	O
as	O
n	O
ones	O
followed	O
by	O
a	O
zero	O
)	O
.	O
</s>
<s>
If	O
a	O
simpler	O
code	O
is	O
desired	O
,	O
one	O
can	O
assign	O
Golomb	O
–	O
Rice	O
parameter	O
(	O
i.e.	O
,	O
Golomb	O
parameter	O
)	O
to	O
the	O
integer	O
nearest	O
to	O
;	O
although	O
not	O
always	O
the	O
best	O
parameter	O
,	O
it	O
is	O
usually	O
the	O
best	O
Rice	O
parameter	O
and	O
its	O
compression	O
performance	O
is	O
quite	O
close	O
to	O
the	O
optimal	O
Golomb	B-Algorithm
code	I-Algorithm
.	O
</s>
<s>
In	O
predictive	O
algorithms	O
,	O
such	O
residues	O
tend	O
to	O
fall	O
into	O
a	O
two-sided	O
geometric	O
distribution	O
,	O
with	O
small	O
residues	O
being	O
more	O
frequent	O
than	O
large	O
residues	O
,	O
and	O
the	O
Rice	O
code	O
closely	O
approximates	O
the	O
Huffman	B-General_Concept
code	I-General_Concept
for	O
such	O
a	O
distribution	O
without	O
the	O
overhead	O
of	O
having	O
to	O
transmit	O
the	O
Huffman	O
table	O
.	O
</s>
<s>
Several	O
lossless	B-Algorithm
audio	O
codecs	O
,	O
such	O
as	O
Shorten	B-Operating_System
,	O
FLAC	B-Application
,	O
Apple	B-Algorithm
Lossless	I-Algorithm
,	O
and	O
MPEG-4	B-Algorithm
ALS	I-Algorithm
,	O
use	O
a	O
Rice	O
code	O
after	O
the	O
linear	B-Algorithm
prediction	I-Algorithm
step	I-Algorithm
(	O
called	O
"	O
adaptive	O
FIR	O
filter	O
"	O
in	O
Apple	B-Algorithm
Lossless	I-Algorithm
)	O
.	O
</s>
<s>
Rice	O
coding	O
is	O
also	O
used	O
in	O
the	O
FELICS	B-Algorithm
lossless	B-Algorithm
image	O
codec	O
.	O
</s>
<s>
The	O
Golomb	O
–	O
Rice	O
coder	O
is	O
used	O
in	O
the	O
entropy	B-Algorithm
coding	I-Algorithm
stage	O
of	O
Rice	O
algorithm	O
based	O
lossless	B-Algorithm
image	O
codecs''	O
.	O
</s>
