The Golumb code:
The Golomb code for non- negative integer n can be an effective Huffman code. The code depends on the choice of parameter b. the first step is to compute the two quantities
Following which, the code is constructed of two parts; the first is the value of , coded in unary, and the second, the binary value of r coded in either bits (for the small remainders) or in bits (for the large ones).
Choosing b=3, e.g., produces three possible remainders 0,1 and 2. They are coded 0, 10, 11 respectively. Choosing b=5 produces the five remainders 0 through 4, which are coded ==, 01, 100, 101 and 110. Table shows some examples of the Golomb code for b=3 and b=5
|
n:
|
1
|
2
|
3
|
4
|
5
|
6
|
7
|
|
b=3
|
0:0
|
0:10
|
0:11
|
10:0
|
10:10
|
10:11
|
110:0
|
|
b=5
|
0:00
|
0:01
|
0:100
|
0:101
|
10:110
|
10:00
|
10:01
|