Unique decodability means that every encoded message has at most one decomposition into codewords.
A code is decipherable, or uniquely decodable, when every finite concatenation of codewords has at most one decomposition into source codewords.
A decipherable code is suffix-free when no codeword is a proper suffix of another. Reversing all its words gives a prefix code. Consequently it is uniquely decipherable: read a concatenation from the right, where the last codeword is determined uniquely, and continue by induction.
For a fixed source distribution and code alphabet, an optimal uniquely decodable code minimizes expected codeword length. Huffman coding gives an optimal binary prefix code, and the equivalence of attainable uniquely-decodable and prefix-code lengths gives the same minimum for both classes.
In a prefix code no codeword is the prefix of another, so concatenated messages have unique instantaneous decoding.
A prefix code whose codewords use a three-symbol alphabet, conventionally . No complete codeword is a prefix of another, permitting sequential decoding by following a code tree to a tree leaf. Its expected codeword length is trits per source symbol. For source probabilities , the codewords give expected codeword length trits.
For a finite source alphabet with at least two symbols and strictly positive weights, every ternary prefix code minimizing weighted codeword length has all internal vertices of outdegree three, except possibly one of outdegree two whose tree children are deepest tree leaves.
To prove this, let be the greatest tree leaf depth. A missing tree child at any depth would permit moving a deepest tree leaf into that vacant branch, strictly reducing its positive weighted cost. Thus all internal vertices above depth have three tree children. Tree parents at depth have only tree leaves as tree children; one tree child would permit contraction and strict improvement. If two such tree parents each had two tree children, move one tree child of the second into the first tree parent's third slot, preserving its depth, and contract the second tree parent's remaining tree child. This again strictly improves cost. There is therefore at most one binary tree parent. If the number of symbols is an odd number, the leaf-count formula for a full ternary tree forces to be an even integer; since , there is no binary tree parent.
Strict positivity matters. For probabilities , the prefix code minimizes expected codeword length at one trit, yet has unary vertices and a deepest tree leaf without a sibling codeword. Removing or rearranging zero-weight branches can select a reduced minimizer, but arbitrary minimizers need not have the positive-weight shape.
Replacing every quaternary digit by its fixed two-bit representation preserves the prefix code property: a binary prefix between translated codewords would end at an even position and hence imply a quaternary prefix. Thus a translated quaternary Huffman code cannot beat binary Huffman coding in expected codeword length.
For the reverse bound, binary prefix code lengths give candidate quaternary lengths . Since , the Kraft inequality supplies such a quaternary prefix code. Optimality of quaternary Huffman coding and give . These quantities are expected codeword lengths for the same source probability distribution.
For a success index with geometric distribution of parameter , write , . Encode by ones followed by zero, then encode in exactly bits. This prefix code has length . Since , its expected length is the displayed expression, at most . Thus a very rare success can be communicated in approximately the logarithm of its inverse probability, rather than one bit per trial.
// Target: quantum-theory.bigb
The prefix tree of a code has vertices corresponding to prefixes of codewords, with one edge for each next symbol. The root represents the empty word. In a prefix code, complete codewords are leaves, and their depths are their codeword lengths.
// Target: computer-science.bigb
The lengths of every decipherable binary code satisfyConversely, any positive integer lengths satisfying this bound can be realized by a prefix code.
The lengths of a finite uniquely decodable code satisfy , even when the code is not a prefix code. Distinct concatenations of codewords remain distinct; counting the possible binary strings of each total length bounds by . Taking th roots proves the claim.
Prescribed positive word lengths admit a decipherable code if and only if they admit a prefix code. Counting length- concatenations of words proves the Kraft inequality for any decipherable code; choosing free vertices of the ordered -ary tree constructs a prefix code whenever this inequality holds. Each prefix code has unique decodability.
If a decipherable binary code has codewords of lengths , thenThis follows by applying the entropy lower bound with the uniform source distribution.
Shannon-Fano coding comprises two related prefix code constructions. Shannon coding assigns lengths to symbols of probability ; Fano coding recursively partitions the ordered symbols into groups of nearly equal total probability and assigns a bit at each partition.
Order source probabilities as , putand take the first binary digits of as the codeword for symbol . Since for , two cumulative probabilities cannot lie in the same dyadic interval selected by the earlier codeword. The resulting code is prefix-free.
If the Shannon length is and is the length of any binary decipherable code, thenThus the probability that the Shannon code loses to another code by or more bits decreases exponentially in .
Every binary prefix code has expected length at least its source entropy; Shannon lengths achieve expected length strictly below .
For a complete binary prefix code with lengths , the Kraft inequality is an equality: . Put . The difference between expected codeword length and Shannon entropy isThe Kullback-Leibler divergence is nonnegative and vanishes exactly when . Hence a complete code is entropy-tight exactly for its dyadic matching source. For example, lengths match probabilities . Being an optimal prefix code among symbol-by-symbol codes is a weaker condition and does not imply this equality.
Articles by others on the same topic
There are currently no matching articles.