You are on page 1of 17

# Page 1 of 17

Report
For
Project 4
Wiener Filtering

ASIF AL – RASHEED
EE 5521
Page 2 of 17

The file P4Data.mat contains three random sequences: x[n], v[n], and r[n], where
[ ] [ ] [ ] r n x n v n = + .
The sequence v[n] is white noise. Estimate the variance
2
v
o of v[n].
The variance
2
v
o = 15.9901

a. Generate sample correlation functions to yield estimates of R
r
[m] and R
xr
[m] from the data. Plot these
correlation functions for | | 100,100 me ÷
Simulation results:

Fig 1: Sample autocorrelation function of the measurement.
Page 3 of 17

Fig 2: Sample cross correlation function of the signal with measurement.

Page 4 of 17

b. Using the estimated correlation functions, compute the FIR Wiener filter for:
1. N = 4
2. N = 8
3. N = 16
We compute the matrix

For all values of N and,

Simulation results:
N=4 N=8 N=16

Filter coefficients

0.0504 0.0451 0.0415
0.0475 0.0419 0.0381
0.0451 0.0392 0.0352
0.0432 0.0368 0.0326
0.0347 0.0301
0.0333 0.0283
0.0318 0.0264
0.0304 0.0245
0.0225
0.0210
[0] [0]
[0] [1] [ 1]
[1] [1]
[1] [0] [ 1]
[ 1] [ 1]
[ 1] [ 2] [0]
xr
r r r
xr
r r r
xr
r r r
R h
R R R N
R h
R R R N
h N R N
R N R N R
(
( (
(
÷
( (
(
( (
( ÷ =
( (
(
( (
(
= ÷ ÷
¸ ¸ ¸ ¸
(
÷ ÷
¸ ¸
1
1 0
ˆ[ ] [ ] [ ] [ ] [ ]
n N
k n N l
x n h n k r k h l r n l
÷
= ÷ + =
= ÷ = ÷
¿ ¿
Page 5 of 17

N=4 N=8 N=16

Filter coefficients
0.0195
0.0184
0.0176
0.0166
0.0159
0.0153

All results are plotted from 10000 to 10099

Fig 3: The signal x[n].
Page 6 of 17

Fig 4: The FIR estimate of x[n], ˆ[ ] x n for N=4.

Fig 5: The error of the FIR estimate of x[n], ˆ[ ] x n for N=4.
Page 7 of 17

Fig 6: The signal with its FIR estimate and error for N=4.

Fig 7: The FIR estimate of x[n], ˆ[ ] x n for N=8.
Page 8 of 17

Fig 8: The error of the FIR estimate of x[n], ˆ[ ] x n for N=8.

Fig 9: The signal with its FIR estimate and error for N=8.
Page 9 of 17

Fig 10: The FIR estimate of x[n], ˆ[ ] x n for N=16
Fig 11: The error of the FIR estimate of x[n], ˆ[ ] x n for N=16.

Page 10 of 17

Fig 12: The signal with its FIR estimate and error for N=8.

N Theoretical mean square errors Time-average squared error
4 0.7951 0.7960
8 0.7131 0.7137
16 0.6498 0.6504

We see that for N = 16 the errors are the least as expected.
Page 11 of 17

c. Generate the sample correlation functions of x[n]. Assume that x[n] has the auto-correlation function:

2
[ ]
m
x x
R m a o = .
where
2
x
o and a are found using curve fitting
Simulation results:
2
x
o
0.9684
a 0.9627

Fig 13: Plot of correlation function and the sample correlation function of x[n] for | | 100,100 me ÷ .
Page 12 of 17

Computation for the IIR Filter:
The correlation functions of the signal and noise are

To generate the IIR Wiener filter, we need the correlation matrix of the measurements:

The cross-correlation of the measurements and the vector being estimated:

The complex cross-spectral density S
xr
(z) is the two-sided z-transform of the cross-correlation function

The complex spectral density S
r
(z) is the two-sided z-transform of the correlation function:

Then,

Continuing,

The second term corresponds to the non-causal part of the impulse response.
( )
2
[ ] 0.9684 0.9627
m m
x x
R m a o = =
2
[ ] [ ] 15.9901 [ ]
v v
R m m m o o o = =
( )
[ ] [ ] [ ] 0.9684 0.9627 15.9901 [ ]
m
r x v
R m R m R m m o = + = +
( )
[ ] [ ] 0.9684 0.9627
m
xr x
R m R m = =
{ }
2
1 1
0.9684(1 (0.9627) ) 0.070895
( ) 0.9684(0.9627)
(1 0.9627 )(1 0.9627 ) (1 0.9627 )(1 0.9627 )
m
xr
S z
z z z z
÷ ÷
÷
= = =
÷ ÷ ÷ ÷
{ }
1
1
1
0.070895
( ) 0.9684(0.9627) 15.9901 [ ] 15.9901
(1 0.9627 )(1 0.9627 )
(1 0.928 ) (1 0.928 )
16.5937
(1 0.9627 ) (1 0.9627 )
m
r
S z m
z z
z z
z z
o
÷
÷
÷
= + = +
÷ ÷
÷ ÷
=
÷ ÷
1
min 1
(1 0.928 )
( )
(1 0.9627 )
z
H z
z
÷
÷
÷
=
÷
0
16.5937 K =
1 1 1
min
( ) 0.070895 (1 0.9627 ) 0.070895
( ) (1 0.9627 )(1 0.9627 ) (1 0.928 ) (1 0.9627 )(1 0.928 )
xr
S z z
H z z z z z z
÷ ÷ ÷
÷
= =
÷ ÷ ÷ ÷ ÷
1 1
1 1 1 1 1 1
(0.928) 0.070895 1 1
0.665
(1 0.9627 )(1 0.928 ) 1 0.9627 1 0.928
z
z z z z
÷ ÷
÷ ÷ ÷ ÷ ÷ ÷
÷ (
= = ÷
(
÷ ÷ ÷ ÷
¸ ¸
Page 13 of 17

Dropping the non-causal term,

The Wiener filter is then,

The corresponding difference equation is:

Simulation results:
Variance of the noise, K
0
= 16.5937
All results are plotted from 10000 to 10099

Fig 14: The signal x[n].

1 1
min
( ) 0.665
( ) 1 0.9627
xr
S z
H z z
÷ ÷
+
(
=
(
÷
¸ ¸
( ) ( )
1
1 1 1
0 min min 0
( ) 1 1 1 0.9627 0.665 0.04
( )
1/ 1 0.928 1 0.9627 1 0.928
xr
iir
S z z
H z
K H z H z K z z z
÷
÷ ÷ ÷
+
(
÷
= = =
(
÷ ÷ ÷
¸ ¸
ˆ ˆ [ ] 0.928 [ 1] 0.04 [ ] x n x n r n = ÷ +
Page 14 of 17

Fig 15: The IIR estimate of x[n], ˆ[ ] x n

Fig 16: The error of the IIR estimate of x[n], ˆ[ ] x n .
Page 15 of 17

Fig 17: The signal with its IIR estimate and error.

Theoretical mean square error 0.6527
Time-average squared error 0.6530

Page 16 of 17

Comparison of FIR and IIR filters:

Fig 18: The signal with its FIR and IIR estimates.
Page 17 of 17

Fig 19: Different Estimation errors.
We reiterate the errors here
Filter type Theoretical mean square errors Time-average squared error

FIR Filter

N
4 0.7951 0.7960
8 0.7131 0.7137
16 0.6498 0.6504
IIR Filter 0.6527 0.6530

Comment:
From the results we see that the FIR filter for N=16 gives the best results.