Golomb coding: Difference between revisions

Content deleted Content added
Rescuing 1 sources and tagging 0 as dead.) #IABot (v2.0.8.6
Line 43:
===Use with signed integers===
 
Golomb's scheme was designed to encode sequences of non-negative numbers. However, it is easily extended to accept sequences containing negative numbers using an ''overlap and interleave'' scheme, in which all values are reassigned to some positive number in a unique and reversible way. The sequence begins: 0, -1−1, 1, -2−2, 2, -3−3, 3, -4−4, 4 ,&nbsp;... The ''n''<sup>-th</sup> negative value (i.e., {{tmath|-n}}) is mapped to the ''n''<sup>th</sup> odd number ({{tmath|2n-1}}), and the ''m''<sup>th</sup> positive value is mapped to the ''m''<sup>-th</sup> even number ({{tmath|2m}}). This may be expressed mathematically as follows: a positive value {{mvar|x}} is mapped to (<math>x^\prime' = 2|x| = 2x,\ x \ge0ge 0</math>), and a negative value {{mvar|y}} is mapped to (<math>y^\prime' = 2|y| - 1 = -2y - 1,\ y < 0</math>). Such a code may be used for simplicity, even if suboptimal. Truly optimal codes for two-sided geometric distributions include multiple variants of the Golomb code, depending on the distribution parameters, including this one.<ref>{{Cite journal | last1 = Merhav | first1 = N. | last2 = Seroussi | first2 = G. | last3 = Weinberger | first3 = M. J. | title = Coding of sources with two-sided geometric distributions and unknown parameters | journal = [[IEEE Transactions on Information Theory]]| volume = 46 | issue = 1 | pages = 229–236 | year = 2000 | doi=10.1109/18.817520}}</ref>
 
== Simple algorithm ==