Question: Problem 4.2 (50 Pts) A source generates symbols a, b, c, d, e, f, and g, with probabilities P(a) = 0.3, P(6)=0.25, P(c) = 0.15,

Problem 4.2 (50 Pts) A source generates symbols a, b, c, d, e, f, and g, with probabilities P(a) = 0.3, P(6)=0.25, P(c) = 0.15, P(d) = 0.10, P(e) = 0.10, P(S) = 0.05, P(g) = 0.05. (a) Construct the Huffman code for these symbols. Calculate the average number of bits per symbol. Calculate the entropy of the source. Compare the entropy and the average number of bits per symbol. (b) Use the following code to construct the Huffman code for the symbols, average num- ber of bits per symbol, and the entropy of the source. Compare the results with those you have found in part (a). p = [0.3 0.25 0.15 0.1 0.1 0.05 0.05]; H = huffman (p); % Codes for each symbol L = [length (H{1}) length (H{2}) length (H{3}) length (H{4}) ... length (H{5}) length (H{6}) length (H{7})]'; % Lengths of codes Bps = p*L; % Average bits per symbol E = -sum (p. *log2 (p)); % Entropy
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
