Geometric Huffman Codinglast update 2011-11-11 — Georg Böcherer (geborg@gmail.com)
Dyadic PMFs can be generated by parsing a stream of independent equiprobable data bits by a full prefix-free code. Formally, References
Downloadsmatching.tar — all implementations from this web site. They are tested in Matlab R2010b and Octave 3.4.0. Geometric Huffman Coding (GHC)Given is a vector
subject to
For comparison, conventional Huffman coding finds the dyadic PMF
ghc.m in matching.tar is a Matlab implementation of GHC. Normalized Geometric Huffman Coding (nGHC)Given is a target vector
subject to nghc.m in matching.tar is a Matlab implementation of nGHC. Cost Constrained Geometric Huffman Coding (ccGHC)Given is a target vector ccghc.m in matching.tar is a Matlab implementation of ccGHC. Miscellaneous m-filesghc.m in matching.tar is a Matlab implementation of Huffman coding. kldiv.m in matching.tar is a Matlab implementation of the Kullback-Leibler distance. ExamplesExample 1example1.m in matching.tar. From Matching Dyadic Distributions to Channels octave:11> addpath /home/georg/matching octave:12> q = [0.328 0.32 0.22 0.11 0.022]'; octave:13> pghc = ghc(q) pghc = 0.50000 0.25000 0.12500 0.12500 0.00000 octave:14> phc = hc(q) phc = 0.25000 0.25000 0.25000 0.12500 0.12500 octave:15> kldiv(pghc,q) ans = 0.13619 octave:16> kldiv(phc,q) ans = 0.19548 octave:17> phc_ = [hc(q(1:4));0] phc_ = 0.25000 0.25000 0.25000 0.25000 0.00000 octave:18> kldiv(phc_,q) ans = 0.15523 octave:19> Example 2example2.m in matching.tar. Comparison of normalized geometric Huffman coding and Huffman coding for the (d,k) = (10,19) constraint. example2.m
w = (11:20)'; C = fsolve(@(s) sum(exp(-w*s))-1,1); t = exp(-w*C); d_nghc = nghc(t,w); d_hc = hc(t); R_nghc = -d_nghc'*log(d_nghc)/(w'*d_nghc); R_hc = -d_hc'*log(d_hc)/(w'*d_hc); disp(['codeword lengths of nghc: ' num2str(-log2(d_nghc'))]); disp(['codeword lengths of hc : ' num2str(-log2(d_hc'))]); disp(['rate achieved by nghc:' num2str(R_nghc)]); disp(['rate achieved by hc: ' num2str(R_hc)]); octave:7> addpath /home/georg/matching octave:7> example2 codeword lengths of nghc: 3 3 3 3 3 3 4 4 4 4 codeword lengths of hc : 2 3 3 3 3 4 4 4 5 5 rate achieved by nghc:0.15273 rate achieved by hc: 0.15265 octave:8> |