|
|
Line 1: |
Line 1: |
| {{redirect|Gamma encoding|the signal processing operation|gamma correction}}
| | Marvella is what you can contact her but it's not the most female name out there. He used to be unemployed but now he is [http://healthyeater.com/diet-food-delivery-services meal delivery] service a pc operator but his promotion by no means arrives. Puerto Rico is exactly where he's been living for years and he will by no means move. The preferred pastime for my healthy food delivery [http://Www.5Squares.com/ children] and me is to [http://Www.Livestrong.com/article/361451-the-best-meal-delivery-plans/ perform baseball] and I'm trying to make it a occupation.<br><br>my website; [http://Cn5.us/diettogoreviews74620 healthy meals delivered] |
| | |
| '''Elias gamma code''' is a [[universal code (data compression)|universal code]] encoding positive integers developed by [[Peter Elias]]<ref name="Elias">{{cite journal | first = Peter | last = Elias | title = Universal codeword sets and representations of the integers | journal = [[IEEE Transactions on Information Theory]] | volume = 21 | issue = 2 | pages = 194–203 |date=March 1975 | url = http://ieeexplore.ieee.org/xpl/freeabs_all.jsp?arnumber=1055349}}</ref>{{rp|197, 199}}. It is used most commonly when coding integers whose upper-bound cannot be determined beforehand.
| |
| | |
| ==Encoding==
| |
| | |
| To code a [[number]]:
| |
| #Write it in [[binary numeral system|binary]].
| |
| #Subtract 1 from the number of bits written in step 1 and prepend that many zeros.
| |
| | |
| An equivalent way to express the same process:
| |
| #Separate the integer into the highest power of 2 it contains (2<sup>''N''</sup>) and the remaining ''N'' binary digits of the integer.
| |
| #Encode ''N'' in [[Unary numeral system|unary]]; that is, as ''N'' zeroes followed by a one.
| |
| #Append the remaining ''N'' binary digits to this representation of ''N''.
| |
| | |
| To represent a number <math>x</math>, Elias gamma uses <math>2 \lfloor \log_2(x) \rfloor + 1</math> bits<ref name="Elias"/>{{rp|199}}.
| |
| | |
| The code begins (the [[implied probability]] distribution for the code is added for clarity):
| |
| | |
| {| class=wikitable
| |
| ! Number !! Encoding !! Implied probability
| |
| |-
| |
| | 1 = 2<sup>0</sup> + ''0'' || <code>1</code> || 1/2
| |
| |-
| |
| | 2 = 2<sup>1</sup> + ''0'' || <code>01''0''</code> || 1/8
| |
| |-
| |
| | 3 = 2<sup>1</sup> + ''1'' || <code>01''1''</code> || 1/8
| |
| |-
| |
| | 4 = 2<sup>2</sup> + ''0'' || <code>001''00''</code> || 1/32
| |
| |-
| |
| | 5 = 2<sup>2</sup> + ''1'' || <code>001''01''</code> || 1/32
| |
| |-
| |
| | 6 = 2<sup>2</sup> + ''2'' || <code>001''10''</code> || 1/32
| |
| |-
| |
| | 7 = 2<sup>2</sup> + ''3'' || <code>001''11''</code> || 1/32
| |
| |-
| |
| | 8 = 2<sup>3</sup> + ''0'' || <code>0001''000''</code> || 1/128
| |
| |-
| |
| | 9 = 2<sup>3</sup> + ''1'' || <code>0001''001''</code> || 1/128
| |
| |-
| |
| | 10 = 2<sup>3</sup> + ''2'' || <code>0001''010''</code> || 1/128
| |
| |-
| |
| | 11 = 2<sup>3</sup> + ''3'' || <code>0001''011''</code> || 1/128
| |
| |-
| |
| | 12 = 2<sup>3</sup> + ''4'' || <code>0001''100''</code> || 1/128
| |
| |-
| |
| | 13 = 2<sup>3</sup> + ''5'' || <code>0001''101''</code> || 1/128
| |
| |-
| |
| | 14 = 2<sup>3</sup> + ''6'' || <code>0001''110''</code> || 1/128
| |
| |-
| |
| | 15 = 2<sup>3</sup> + ''7'' || <code>0001''111''</code> || 1/128
| |
| |-
| |
| | 16 = 2<sup>4</sup> + ''0'' || <code>00001''0000''</code> || 1/512
| |
| |-
| |
| | 17 = 2<sup>4</sup> + ''1'' || <code>00001''0001''</code> || 1/512
| |
| |}
| |
| | |
| ==Decoding==
| |
| | |
| To decode an Elias gamma-coded integer:
| |
| #Read and count 0s from the stream until you reach the first 1. Call this count of zeroes ''N''.
| |
| #Considering the one that was reached to be the first digit of the integer, with a value of 2<sup>''N''</sup>, read the remaining ''N'' digits of the integer.
| |
| | |
| ==Uses==
| |
| | |
| Gamma coding is used in applications where the largest encoded value is not known ahead of time, or to [[Data compression|compress]] data in which small values are much more frequent than large values.
| |
| | |
| == Generalizations ==<!-- This section is linked from [[Elias delta coding]] -->
| |
| Gamma 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.
| |
| | |
| [[Exponential-Golomb coding]] generalizes the gamma code to integers with a "flatter" power-law distribution, just as [[Golomb coding]] generalizes the unary code.
| |
| It involves dividing the number by a positive divisor, commonly a power of 2, writing the gamma code for one more than the quotient, and writing out the remainder in an ordinary binary code.
| |
| | |
| ==References==
| |
| | |
| {{Reflist}}
| |
| * {{cite book | first = Khalid | last = Sayood | title = Lossless Compression Handbook | publisher = Elsevier | year = 2003 | chapter = Levenstein and Elias Gamma Codes | isbn = 978-0-12-620861-0}}
| |
| | |
| ==See also==
| |
| *[[Elias delta coding]]
| |
| *[[Elias omega coding]]
| |
| | |
| {{Compression Methods}}
| |
| | |
| {{DEFAULTSORT:Elias Gamma Coding}}
| |
| [[Category:Numeral systems]]
| |
| [[Category:Lossless compression algorithms]]
| |
| [[Category:Articles with example C code]]
| |
Marvella is what you can contact her but it's not the most female name out there. He used to be unemployed but now he is meal delivery service a pc operator but his promotion by no means arrives. Puerto Rico is exactly where he's been living for years and he will by no means move. The preferred pastime for my healthy food delivery children and me is to perform baseball and I'm trying to make it a occupation.
my website; healthy meals delivered