In this problem, you will write a computer program to design a vector quantizer and generate a codebook of size $[L \times N]$. Here, $L$ is the number of codebook entries and $N$ is the codebook dimension.
Step 1
Generate a training set, $T_{i n}$, of size $[L n \times N]$, where $n$ is the number of training vectors per codevector. Assume $L=16, N=4$, and $n=10$. Denote the training set elements as $t_{i n}(i, j)$, for $i=0,1, \ldots, 159$ and $j=0,1,2,3$. Use Gaussian vectors of zero mean and unit variance for training.
Step 2
Using the LBG algorithm [Lind80], design a vector quantizer and generate a codebook, $\boldsymbol{C}$, of size $[L \times N]$, i.e., $[16 \times 4]$. In the LBG VQ design, choose the distortion threshold as 0.001 . Label the codevectors as $c(i, j)$, for $i=$ $0,1, \ldots, 15$ and $j=0,1,2,3$.
FIGURE CANT COPY
Figure 3.23. Four-bit VQ design specifications for Problem 3.9.
Step 3
Similar to Step 1 generate another training set, $T_{\text {out }}$ of size $[160 \times 4]$ that we will use for testing the VQ performance. Label these training set values as $t_{\text {out }}(i, j)$, for $i=0,1, \ldots, 159$ and $j=0,1,2,3$.
Step 4
Using the codebook, $\boldsymbol{C}$, designed in Step 2, perform vector quantization of $t_{\text {in }}(i, j)$ and $t_{\text {out }}(i, j)$. Let us denote the VQ results as $\hat{t}_{\text {in }}(i, j)$ and $\hat{t}_{\text {out }}(i, j)$, respectively.
a. When the test vectors are within the training sequence, compute the over-all SNR and segmental SNR values as follows,
$$
\begin{aligned}
S N R_{\text {overall }} & =\frac{\sum_{i=0}^{L n-1} \sum_{j=0}^{N-1} t_{i n}^2(i, j)}{\sum_{i=0}^{L n-1} \sum_{j=0}^{N-1}\left(t_{i n}(i, j)-\hat{t}_{i n}(i, j)\right)^2} \\
S N R_{\text {segmental }} & =\frac{1}{L n} \sum_{i=0}^{L n-1} \frac{\sum_{j=0}^{N-1} t_{i n}^2(i, j)}{\sum_{j=0}^{N-1}\left(t_{i n}(i, j)-\hat{t}_{i n}(i, j)\right)^2}
\end{aligned}
$$
b. Compute the over-all SNR and segmental SNR values when the test vectors are different from the training ones, i.e., replace $t_{i n}(i, j)$ with $t_{\text {out }}(i, j)$ and $\hat{t}_{\text {in }}(i, j)$ with $\hat{t}_{\text {out }}(i, j)$ in (3.57) and (3.58).
c. List in Table 3.6 the overall and segmental SNR values for different number of codebook entries and different codebook dimensions. Explain the effects of choosing different values of $L, n$, and $N$ on the SNR values.
d. Compute the MSE, $\quad \varepsilon\left(t_{i n}, \hat{t}_{i n}\right)=\frac{1}{L n} \frac{1}{N} \sum_{i=0}^{L n-1} \sum_{j=0}^{N-1}\left(t_{i n}(i, j)-\right.$ $\left.\hat{t}_{i n}(i, j)\right)^2$ for different cases, e.g., $L=16,64, n=10,100,1000$, $N=2,8$. Explain how the MSE varies for different values of $L, n$, and $N$.