I need to find the coefficients (impulse response) of a FIR Wiener filter with length equal to 2. I have a gaussian white noise signal that is generated using the Standard Normal Distribution (mean = 0, var = 1). I also have a seperate system that "colors" the white noise signal. It alters the PSD of the signal so that is it not uniform.
Then I need to input the "colored" noise signal into the FIR Wiener filter, which needs to approximate the original white noise signal,w(n).
Let's call this white noise approximation w_hat(n). So I want to: w_hat(n) ~ w(n), where w_hat(n) is the output of the Wiener filter.
The colored noise signal is the following : v(n) = 0.6v(n-1) + w(n) , where w(n) is the gaussian white noise signal.
I know that, theoretically, the optimal Wiener filter, can be found by solving the Wiener-Hopf equation, i.e minimizing the expected value of the MSE between w(n) and w_hat(n), over the filter's impulse response. However I am having a hard time implementing this in MATLAB.
We also know that this is the Frequency Response of the optimal Wiener filter (sorry can't post an image due to low reputation),
where in the numerator there is the PSD of w(n) and v(n), (i.e the DTFT of their crosscorrelation) and in the denominator is the PSD of v(n).
What I have tried so far is the following :
- Compute the croscorrelation between the (ideal) white noise w(n) and the filter's input v(n), using MATLAB's xcorr, store the result into
- Finding its DTFT using
abs(fftshift(fft(r_wv))), store into
- Compute the autocorrelation of the input signal v(n), using xcorr(), store the result into
- Finding its DTFT like in step 2, store into
- Get the filter's Frequency Response, as mentioned above, by doing
phi_vv ./ phi_wv, store the result into
- Finally, apply IDTFT, in order to compute the filter's impulse response. I use
However the impulse response I get this way is a complex one, and not a real one, and more importantly it has the same length as the signals used (1001 samples), and not the desired length of 2.
EDIT: I know that I have to solve this linear system. However, I am confused as to how I would compute, say Rvv(0) .
Any help, is greatly appreciated as I have been stuck on this for a few days.
The code :
n = 0 : 1000; % number of samples w = randn(1, length(n)); %white noise signal v = filter(1, [1, -0.6], w); % the "colored" white noise signal [r_v, lags] = xcorr(v); %compute autocorrelation of v(n) phi_vv = abs(fftshift(fft(r_v))); %compute its DTFT, i.e PSD [r_wv,lags2] = xcorr(w,v); %compute crosscorrelation of w(n) and v(n) phi_wv = abs(fftshift(fft(r_wv))); % compute its DTFT freq_resp = phi_wv ./ phi_vv; % compute the filter's Frequency Response hW = abs(ifftshift(ifft(freq_resp))); % use IDTFT in order to get its impulse response w_hat = filter(hW, 1, v); % filter the "colored" noise signal, to get an approximation of the white noise