Unary coding: Difference between revisions

Content deleted Content added
Merged contents of "unary code".
optimally efficient '''only''' for constrained integer-size codes...
Line 5:
:<math>\operatorname{P}(n) = 2^{-n}\,</math>
 
for <math>n=1,2,3,...</math>. It is in fact optimal for any [[geometric distribution]]
 
When comparing only the subset of encoders with an integer number of symbols in the output code, it is optimal for any [[geometric distribution]]
 
:<math>\operatorname{P}(n) = (k-1)k^{-n}\,</math>
Line 14 ⟶ 16:
 
for <math>n=1,2,3,...</math>.
 
Note that these two distributions can be encoded more efficiently with [[arithmetic coding]] (by allocating a non-integer number of symbols per code), so unary encoding is '''not''' optimally efficient for these distributions according to [[Claude Shannon|Shannon's]] [[source coding theorem]].
 
A modified unary encoding is used in [[UTF-8]]. Unary codes are also used in split-index schemes like the [[Golomb Rice code]]. Unary coding is [[Prefix-free code|prefix-free]], and can be uniquely decoded.