0
$\begingroup$

Question

Question:

My interpretation My interpretation:

Work

I'm attempting to do this in MATLAB.

I know that for discrete Random Processes going into an LTI system the autocorrelation function of the output is $R_y[n] = h[n]\star h[-n]\star R_x[n]$ where $\star$ is convolution.
The two tap Haar filters are: h1 = [0.707 0.707] and h2 = [0.707 -0.707] which are orthonormal to each other.

I also know that transform coding gain is defined this way:
$$G = \frac{1}{N}\frac{\displaystyle\sum_{i=0}^{N-1} \sigma_i^2}{\left(\displaystyle\prod_{i=0}^{N-1} \sigma_i^2\right)^{\frac 1N}}$$

where $N$ is the number of samples (3 in this case?) and $\sigma_i$ is the variance of the $i$th transform coefficient.

This is my code:

h1 = 1/sqrt(2).*[1 1];  
h2 = 1/sqrt(2).*[1 -1];  
y1 = conv(x,conv(h1,fliplr(h1)))  
y1 = 4.6500   14.3000   19.3000   14.3000    4.6500  
y2 = conv(x,conv(h2,fliplr(h2)))
y2 = -4.6500    4.3000    0.7000    4.3000   -4.6500

After decimation:

Y1 = 4.6500   19.3000    4.6500
Y2 = -4.6500    0.7000   -4.6500

Calculated coding gains:

GTC1 = 9.533/(417.3134)^(1/3) = 1.2757
GTC2 = -2.8667/(15.1358)^(1/3) = -1.1589

My questions:

Am I calculating $y_1$ and $y_2$ correctly? As I understand it these are supposed to be the autocorrelation functions for a WSS Gaussian random process (because WSS into LTI gives WSS out). After decimation, can i use $Y_1$ and $Y_2$ to calculate coding gain? I'm getting a negative coding gain for the second channel ($Y_2$), does that make sense?

EDIT: Just realized that the Haar filters need not be 2 tap filters. Now I am more lost than before.

$\endgroup$
0
$\begingroup$

I am not sure why you're trying to do this in MATLAB. This can be done quite easily with pen and papers.


Another way of seeing what you're doing here is the following:

  1. Build vectors of size 2 from the sequence $X$ $$[X(0),~X(1)], [X(2),~X(3)], [X(4),~X(5)]\dots$$
  2. Apply an orthogonal transform on each vector to obtain the corresponding transform coefficients $Y$.

The order 2 orthogonal transform you're using can mathematically be written as $$\begin{bmatrix}Y_0 \\ Y_1\end{bmatrix} = \frac{1}{\sqrt{2}}\begin{bmatrix}1 & 1 \\ 1 & -1\end{bmatrix}\begin{bmatrix}X(n) \\ X(n+1)\end{bmatrix}$$ where $Y_0$ and $Y_1$ are the transform coefficients and $X(n)$ and $X(n+1)$ are successive (hence correlated) samples from the process to be compressed. From this, you can easily compute $\sigma^2_0$ (the variance of $Y_0$) and $\sigma^2_1$ (the variance of $Y_1$). Indeed, because $X$ is zero-mean (and so are the transform coefficients), you know that $$\sigma^2_i = R_{Y_i}(0) = E\{Y_iY^*_i\}$$ for $i = 1, 2$. Then, you simply need to plug in the expression of $Y_i$ as a function of $X(n)$ and $X(n+1)$ to find $\sigma^2_i$ as a function of $R_X(0)$ and $R_X(\pm1)$. At the end, you should obtain $$\sigma^2_0 = R_X(0) + R_X(1) = 19.3,$$ $$\sigma^2_1 = R_X(0) - R_X(1) = 0.7.$$ You can clearly see from this the energy compaction in the first transform coefficient, which will contributes to the coding gain. You now have everything you need to compute the coding gain (note that $N$ in your expression for the coding gain is the number of transform coefficients, 2 in this case).

$\endgroup$
  • $\begingroup$ I don't think this is correct because it doesn't say anywhere in the question to use two-tap Haar filters. I thought of another approach which involves determining the Power Spectral Density of the outputs of each channel and then taking the inverse FT to obtain the autocorrelation function of the outputs but I'm not sure how to proceed. Link to an image of my work: My Work $\endgroup$ – yellow_watermelon Jun 18 '17 at 16:56
  • $\begingroup$ I think you're making your life harder than it is. The two-channels Haar wavelet filter you describe in your question is equivalent to the matrix notation I used in my answer. See for example this. $\endgroup$ – anpar Jun 18 '17 at 16:56
  • $\begingroup$ I understand its equivalent. The issue is that the question does not specify the type of Haar filter, it just says "made from the Haar wavelet filters (i.e. just one stage of the Haar wavelet transform)" So why would I assume that I should be using the two-tap Haar filters? Why not 4 or 8 or 16? $\endgroup$ – yellow_watermelon Jun 18 '17 at 17:00
  • $\begingroup$ Doesn't the fact that the we're discussing a two-channel filter bank constraints the Haar filter to a two-tap filter? $\endgroup$ – anpar Jun 18 '17 at 17:22
  • $\begingroup$ I don't think so, why would it? I'm not aware of any constraint on the length of the Haar filter that relates to the number of channels in the system. Could you show me such a relation if there is one? The only constraint I'm aware of on the length of Haar filters is that they have to be even length. $\endgroup$ – yellow_watermelon Jun 18 '17 at 17:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.