HW10 - Optimal Filter Wiener

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

1ING09 - Digital Signal Processing

Homework 10: Filter design (Optimal filter - Wiener)

1. Passing a white noise process V [n] through an IIR filter results in a special kind of random pro-
cess, called autorregresive (AR) process X[n]. For a first-order autorregresive process (AR(1)), it’s
autocorrelation is given by:
rx (k) = α|k|
Design a 1-step Wiener predictor of length 2, namely xest [n + 1] = h0 x[n] + h1 x[n − 1], where h0 and
h1 are the filter coefficients, by solving the Wiener-Hopf equation. What do you think would happen
if we used a Wiener filter with more coefficients?
2. Consider an auto-regressive process x(n) generated by passing white noise v(n) through a system with
transfer function:
1
H(z) =
1 − 0.08z −1 − 0.9z −2
a. Find the diference equation that governs the behaviour of process x(n).
b. If a Wiener filter of length 3 is used to predict the next value x̂(n + 1) of the process, what will be
the optimal coefficients for such filter? Explain.
3. A common application of Wiener filtering is referred to as noise cancellation. The setup consists
in using two sensors: one that measures a (usually noisy) interest signal, and one that measures a
reference of the noise present in the medium. A schematic of this setup can be seen on Figure 1. To
evaluate the effectiveness of the Wiener filter in the noise cancelling problem, you are tasked with
performing the following steps:
a. Generate the desired signal d[n] = sin(2πnw0 ), considering w0 = 0.025, and a sample vector
n ∈ [0, 200]
b. Now you must generate the noise signals. For this, keep in mind that the measured noise signals
v1 [n] and v2 [n] are not identical, but come from the same original white Gaussian noise source (v[n]),
which has been transformed/distorted after traveling through a medium (which we can consider to
be an LTI system). To this end, assume that the measured noise signal v1 [n] arrived at the sensor
after travelling through a medium with transfer function:
1
H1 (z) =
1 − 0.8z −1
and the noise measured at the second sensor traveled through a similar medium with transfer
function:
1
H2 (z) =
1 + 0.6z −1
To generate the measured noise sequences:

Figure 1: Noise cancelling system with Wiener filter

1
i. Generate a 200-sample long zero-mean white Gaussian noise sequence v[n] with variance σ 2 = 1
using the randn() command.
ii. Generate the measured noise sequences v1 [n] and v2 [n] by filtering v[n] with the medium transfer
functions H1 (z) and H2 (z) respectively, using the filter() commands.
Finally, sum the measured noise signal v1 [n] and the desired signal d[n] to get the total signal
measured by sensor 1, x[n] = d[n] + v1 [n]. In the same figure, plot the desired signal (d[n]), the
measured signal(x[n]), and the reference measured noise (v2 [n]).
c. The objective of noise cancellation is for our Wiener filter to provide an estimate of the noise in the
main sensor v1 [n], using the information contained in v2 [n], which makes v2 [n] our ‘target’ signal.
Calculate the autocorrelation vector of v2 [n] by using the xcorr() command.
d. Using the autocorrelation vector obtained in c, generate the autocorrelation matrix Rv by consid-
ering only p = 6 elements of the autocorrelation vector (use the toeplitz() command).
e. Calculate the cross-correlation rxv between the ‘reference’ signal x[n] and v2 [n]
f. Solve the Wiener-Hopf equations Rv h = rxv to get the optimal Wiener filter coefficients h. Use the
coefficients to get the noise estimate vest [n]. Get the estimate of the desired signal d[n] by making
the substraction dest [n] = x[n] − vest [n]. Plot the estimate of the desired signal.
g. Repeat items c through f, but considering p = 12 elements of the autocorrelation and cross-
correlation vectors. What differences do you observe in the result?
4. Audacity is an audio processing open-source software. It is commonly used to record instruments,
and voice from different audio interfaces and to produce music. One of the plug-ins in the software is
named Noise Reduction and it uses a Wiener filter to clean the input signal based on a noise pattern
taken from the same recording device.
With the same device, you record two signals: x[n], the noisy observed signal; and, v2 [n], the noise
pattern. Figure 1 shows the proposed system to recover the clean signal d[n] from the observed noisy
sequence x[n]. The system aims to estimate the original noise signal v1 [n] based on the recorded noise
pattern v2 [n] in order to recover d[n]. You also know that the original white noise follows a white
gaussian distribution N(0,σ 2 ).
a. Find the Wiener-Hopf equations of the system shown in Figure 2. Give your answer in the comments.
b. Load the file data.mat. You will find both x[n] and v2 [n] signals. In the same figure, plot both
signals. Label your figure correctly.
c. Implement the system equations and find the coefficients of the Wiener filter using p = 12.
d. Estimate the signal d[n] and plot the estimated signal with the filter found in c)

Figure 2: System for Audacity audio processing.

2
5. Design a predictive Wiener filter based on the system in Figure 3 and the following input signals.
 π 
µ(n) = 25 sin n
256
η(n) ∼ N (0, 1)
n ∈ [0, 1023]

Figure 3: Wiener filter system.

ˆ
a. Find the coefficients of the system for p = {5, 20, 50} with m = 5. Plot the signals µ(n), d(n), d(n),
and e(n).
ˆ
b. Find the coefficients of the system for p = {5, 20, 50} with m = 50. Plot the signals µ(n), d(n), d(n),
and e(n).
ˆ
c. Find the coefficients of the system for p = {5, 20, 50} with m = 100. Plot the signals µ(n), d(n), d(n),
and e(n).
Solution:
We generate a single script for the three questions. We vary the parameter p which is the order of the
system and the offset m accordingly.

1 % −−− Wiener filter parameters −−− %


2 order = 50; % filter order −−> p = {5, 20, 50}
3 offset = 100; % offset −−> m = {5, 50, 100}

We generate the sequences to be analyzed by the predictive Wiener filter.

1 % −−− Sequences −−− %


2 fs = 100; % sampling frequency
3 fu = 1/256; % frequency of x[n]
4 n size = 1024; % size of vector n
5 n v = 0:n size−1; % discrete time samples
6 u v = 25*sin(2*pi*fu* n v); % desired signal without noise
7 n var = 1; % white noise variance (0 mean)
8 eta v = sqrt(n var)*randn(1,n size); % white noise
9 y v = u v + eta v; % desired signal

We implement the delay z −m and define the signal d(n).

1 % −−− Delay −−− %


2 d = y v; % desired signal ahead of x
3 x v = [ zeros( 1, offset) y v( 1: end− offset)]; % signal lagging behind signal d

We calculate the parameters of the predictive Wiener filter and the estimated signal.

1 % −−− Predictive Wiener filter coefficients −−− %


2 [r, lags r] = xcorr(d,x v); % cross−correlation dx
3 [rr, lags rr] = xcorr(x v); % autocorrelation x

3
4 r idx = find(lags r == 0); % locate n = 0
5 rr idx = find(lags rr == 0); % locate n = 0
6
7 r part = r(1,r idx:r idx+order−1); % vector \rho= [r {dx}(0) ... r {dx}(P−1)]
8 rr part = rr(1,rr idx:rr idx+order−1); % vector [r {xx}(0) ... r {xx}(P−1)]
9 rr mat = toeplitz(rr part); % autocorrelation matrix \upsilon
10 w = rr mat\transpose(r part); % linear system solution
11 d hat = conv(x v, w); % estimated signal

Plot the signals analyzed. We show in Figure 4 the graphics for p = 50 and m = 100.

1 % −−− Plots −−− %


2 f01 = figure;
3 plot( d, '−ro'); hold on;
4 plot( x v, '−ko'); hold on;
5 plot( d hat, '−bo');
6 legend('desired sig. $d[n]$','delayed sig. $x[n]$', 'estimated sig. ...
$\hat{d}[n]$','interpreter','latex');
7 title('Predictive Wiener Filter')

Figure 4: Solution for p = 50, and m = 100.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy