Elias gamma coding
Encyclopedia
|
| Tutorials | Encyclopedia | Dictionary | Directory |
|
Elias gamma coding
Elias gamma code is a universal code encoding positive integers. It is used most commonly when coding integers whose upper-bound cannot be determined beforehand. To code a number:
An equivalent way to express the same process:
The code begins: Implied probability 1 = 20 + 0 = 1 1/2 2 = 21 + 0 = 010 1/8 3 = 21 + 1 = 011 " 4 = 22 + 0 = 00100 1/32 5 = 22 + 1 = 00101 " 6 = 22 + 2 = 00110 " 7 = 22 + 3 = 00111 " 8 = 23 + 0 = 0001000 1/128 9 = 23 + 1 = 0001001 " 10 = 23 + 2 = 0001010 " 11 = 23 + 3 = 0001011 " 12 = 23 + 4 = 0001100 " 13 = 23 + 5 = 0001101 " 14 = 23 + 6 = 0001110 " 15 = 23 + 7 = 0001111 " 16 = 24 + 0 = 000010000 1/512 17 = 24 + 1 = 000010001 " ... The implied probability distribution for the code is added for clarity. To decode an Elias gamma-coded integer:
Gamma coding is used in applications where the largest encoded value is not known ahead of time, or to compress data in which small values are much more frequent than large values.
GeneralizationsGamma coding does not code zero or negative integers. One way of handling zero is to add 1 before coding and then subtract 1 after decoding. Another way is to prefix each nonzero code with a 1 and then code zero as a single 0. One way to code all integers is to set up a bijection, mapping integers (0, 1, -1, 2, -2, 3, -3, ...) to (1, 2, 3, 4, 5, 6, 7, ...) before coding. Example codeEncode Decode See alsoExternal links
Source: Wikipedia | The above article is available under the GNU FDL. | Edit this article
|
|
top
©2008-2009 TutorGig.com. All Rights Reserved. Privacy Statement