Golomb coding is a form of entropy encoding invented by Solomon W. Golomb that is optimal for alphabets following geometric distributions, that is, when small values are vastly more common than large values. If negative values are present in the input stream then a overlap and interleave scheme is used, where all non-negative inputs are mapped to even numbers (x'=2x), and all negative numbers are mapped to odd numbers (x'=2.abs(x)+1).
It uses a tunable parameter b to divide an input value into two parts: , the result of a division by b, and , the remainder. The quotient is sent in unary coding, followed by the remainder in truncated binary encoding. When Golomb coding is equivalent to unary coding.
Formally, the two parts are given by the following expression, where is the number being encoded:
and
The final result looks like:
Note that can be of a varying number of bits, and is specifically only b-bits for Rice code, and switches between b,b+1 bits for Golomb code (i.e b is not a power of 2); when r lies between 0,2^log2(b)-b, r takes a b bit representation, and when r is in the interval 2^log2(b) to b, we have a b+1 bit representation.
The parameter b is a function of the corresponding Bernoulli process, which is parameterized by the probability of success in a given Bernoulli Trial. and are related by these inequalities:
The Golomb code for this distribution is equivalent to the Huffman code for the same probabilities, if it were possible to compute the Huffman code.
Rice coding is a special case of Golomb coding first described by Robert Rice. It is equivalent to Golomb coding where the tunable parameter is a power of two. This makes it extremely efficient for use on computers, since the division operation becomes a bitshift operation and the remainder operation becomes a bitmask operation.
1. Fix the parameter M to an integer value.
2. For the number to be encoded, say N, find out
This article is licensed under the GNU Free Documentation License.
It uses material from the
"Golomb coding".
Home Page • arts • business • computers • games • health • hospitals • home • kids & teens • news • physicians • recreation• reference • regional • science • shopping • society • sports • world