Docsity

Digital Comm Theory HW2: Huffman Coding & Nonuniform Quantization, Assignments of Theories of Communication

Toggle sidebar
bg1
ECE-542 Digital Communication Theory
Spring 2004
Homework Assignment 2 (Source Coding and Quantization)
Due date: Feb. 12, 2004
1) Huffman coding: Write a code that implements a Huffman encoder for an arbitrary number of
symbols and their associated probabilities.
1. Obtain an ASCII text file containing no less than 5000 words (e.g., use the count function
in Word, say, to determine the approximate size) and identify all the ASCII symbols in it
(including spaces).
2. Calculate the empirical probabilities for the occurrence of each symbol and compute the
empirical entropy of the source (considering each ASCII output as an individual symbol).
3. Use these probabilities to generate the Huffman code, compute the compression ratio and the
code efficiency.
4. Now perturb each calculated symbol probability randomly and independently by ±η%, where
η= 10, and make sure that the probabilities still add up to one (e.g., by re-normalize the
perturbed probabilities so that they sum up to one). Now obtain the Huffman according to
the perturbed (i.e., wrong) probabilities code and calculate the compression and the coding
efficiency in this case. Interpret your results.
5. Repeat the previous part using η= 30. Comment on your results (using typed, good English).
2) Nonuniform quantization: Consider a random signal X(t) whose first-order pdf is given by:
fX(x)=1−|x|,|x|≤1
0,elsewhere.
The signal X(t) is clipped using the compressor φto yield the clipped signal Y(t)=φ(X(t)). The
input-output characteristics of the compressor are given by:
φ(x)=x, |x|≤A
0,elsewhere,
where A<1, is a specified constant. The signal Yis to be quantized using a four-level nonuniform
quantizer with levels −A≤−q2<−q1<0<q
1<q
2≤A, and boundaries −b(between −q2and
−q1)andb(between q1and q2).
1. Determine the first-order pdf of Y(t).
2. Find the quantization levels q1and q2and the boundary bthat minimize the mean-square
error (MSE) between the quantized signal and the clipped signal Y. (Assume that b≤A.)
3. Calculate the MSE assuming hereafter that A=0.85.
4. Simulate the operation of the optimal quantizer (e.g., using Matlab) to estimate the MSE.
Compare it to the theoretical MSE.
5. From your calculations in the first part, you should know that for any fixed boundary value
b, there is an optimal q1and q2. Use simulation to generate the following plot: the MSE
as a function of b. In particular, for each choice of b, theoretically calculate the optimal
quantization levels (for that b), and then use simulation to estimate the MSE for that choice
of b.Atwhichvalueofbthe simulated MSE is at a minimum? Comment on your results.
1

Partial preview of the text

Download Digital Comm Theory HW2: Huffman Coding & Nonuniform Quantization and more Assignments Theories of Communication in PDF only on Docsity!

ECE-542 Digital Communication Theory Spring 2004 Homework Assignment 2 (Source Coding and Quantization) Due date: Feb. 12, 2004

  1. Huffman coding: Write a code that implements a Huffman encoder for an arbitrary number of symbols and their associated probabilities.
  1. Obtain an ASCII text file containing no less than 5000 words (e.g., use the count function in Word, say, to determine the approximate size) and identify all the ASCII symbols in it (including spaces).
  2. Calculate the empirical probabilities for the occurrence of each symbol and compute the empirical entropy of the source (considering each ASCII output as an individual symbol).
  3. Use these probabilities to generate the Huffman code, compute the compression ratio and the code efficiency.
  4. Now perturb each calculated symbol probability randomly and independently by ±η%, where η = 10, and make sure that the probabilities still add up to one (e.g., by re-normalize the perturbed probabilities so that they sum up to one). Now obtain the Huffman according to the perturbed (i.e., wrong) probabilities code and calculate the compression and the coding efficiency in this case. Interpret your results.
  5. Repeat the previous part using η = 30. Comment on your results (using typed, good English).
  1. Nonuniform quantization: Consider a random signal X(t) whose first-order pdf is given by:

fX (x) =

{ 1 − |x|, |x| ≤ 1 0 , elsewhere.

The signal X(t) is clipped using the compressor φ to yield the clipped signal Y (t) = φ(X(t)). The input-output characteristics of the compressor are given by:

φ(x) =

{ x, |x| ≤ A 0 , elsewhere,

where A < 1, is a specified constant. The signal Y is to be quantized using a four-level nonuniform quantizer with levels −A ≤ −q 2 < −q 1 < 0 < q 1 < q 2 ≤ A, and boundaries −b (between −q 2 and −q 1 ) and b (between q 1 and q 2 ).

  1. Determine the first-order pdf of Y (t).
  2. Find the quantization levels q 1 and q 2 and the boundary b that minimize the mean-square error (MSE) between the quantized signal and the clipped signal Y. (Assume that b ≤ A.)
  3. Calculate the MSE assuming hereafter that A = 0.85.
  4. Simulate the operation of the optimal quantizer (e.g., using Matlab) to estimate the MSE. Compare it to the theoretical MSE.
  5. From your calculations in the first part, you should know that for any fixed boundary value b, there is an optimal q 1 and q 2. Use simulation to generate the following plot: the MSE as a function of b. In particular, for each choice of b, theoretically calculate the optimal quantization levels (for that b), and then use simulation to estimate the MSE for that choice of b. At which value of b the simulated MSE is at a minimum? Comment on your results.