Golomb coding: Difference between revisions

Content deleted Content added
Use for run-length encoding: note until we sort this out
Line 126:
== Use for run-length encoding ==
 
:''Note that {{mvar|p}} and {{math|1 – p}} are reversed in this section compared to the use in earlier sections.''
 
Given an alphabet of two symbols, or a set of two events, ''P'' and ''Q'', with probabilities ''p'' and (1&nbsp;&minus;&nbsp;''p'') respectively, where ''p''&nbsp;≥&nbsp;1/2, Golomb coding can be used to encode runs of zero or more ''P''<nowiki>'</nowiki>s separated by single ''Q''<nowiki>'</nowiki>s. In this application, the best setting of the parameter ''M'' is the nearest integer to <math> \frac{-1}{\log_{2}p}</math>. When ''p'' = 1/2, ''M'' = 1, and the Golomb code corresponds to unary (''n''&nbsp;≥&nbsp;0 ''P'''s followed by a ''Q'' is encoded as ''n'' ones followed by a zero). If a simpler code is desired, one can assign Golomb–Rice parameter <math>b</math> (i.e., Golomb parameter <math>M=2^b</math>) to the integer nearest to <math>- \log_2(-\log_2 p)</math>; although not always the best parameter, it is usually the best Rice parameter and its compression performance is quite close to the optimal Golomb code. (Rice himself proposed using various codes for the same data to figure out which was best. A later [[Jet Propulsion Laboratory|JPL]] researcher proposed various methods of optimizing or estimating the code parameter.<ref>{{Cite techreport | last1 = Kiely | first1 = A. | title = Selecting the Golomb Parameter in Rice Coding | number = 42-159 | institution = [[Jet Propulsion Laboratory]] | year = 2004}}</ref>)