1) IntroductionPermalink
The objective for the Wiener filter is to retrieve a desired signal s(n) in noise v(n) given the observed signal x(n) i.e.:
x(n)=s(n)+v(n).
The time domain Wiener filter is a linear minimum mean square error estimator (LMMSEE) with optimal filter coefficients w∗ that satisfy following optimization problem:
w∗=arg minwE[(s(n)−wTx(n))2],
where w=[w0,…,wM−1]T∈RM and x(n)=[x(n),x(n−1)…,x(n−M+1)]T∈RM such that the LMMSE estimate of s(n) given x(n) is:
ˆs(n)=w∗Tx(n).
2) AssumptionsPermalink
Assumption | Mathematical description | |
---|---|---|
1. s(n) and v(n) are uncorrelated. | E[s(n)v(n)]=0 | |
2. v(n) is a white Gaussian noise. | v(n)∼N(0,σ2v) | |
3. The noise variance σ2v. | Known |
3) SolutionPermalink
The Wiener filter is given as
w∗=ˆR−1xxˆrxs,
where ˆRxx∈RM×M is the sample estimate of the autocorrelation matrix of x(n) and ˆrxs∈RM is the sample estimate of the cross-correlation vector between s(n) and x(n).
4) Step-by-step guidePermalink
- Set filter length e.g. M=20.
-
Set autocorrelation of the noise to
rvv(k)=σ2vδ(k),for k=0,…,M−1
where δ(k) is the Kronecker delta function and k is the lag-index.
-
Compute the unbiased sample estimate of the autocorrelation of x(n)
ˆrxx(k)=1N−kN−k−1∑n=0x(n)x(n+k),for k=0,...,M−1or equivalently
ˆrxx(k)=1N−kxT(n)x(n+k),for k=0,...,M−1where x(n)=[x(0),...,x(N−k−1)]T and x(n+k)=[x(k),...,x(N−1)]T.
-
Estimate the autocorrelation of s(n) as
ˆrss(k)=ˆrxx(k)−rvv(k) - Form the autocorrelation matrix ˆRxx of x(n)
-
Form the cross-correlation vector between x(n) and s(n)
ˆrxs(k)=ˆrss(k) -
Compute the Wiener filter coefficients
w∗=ˆR−1xxˆrxs -
Perform filtering
ˆs(n)=w∗Tx(n)
5) MATLAB codePermalink
A MATLAB example is provided where the signals are artificially generated.
% Copyright 2020: DSPCookbook
clc, clear, close all
% Constants in simuation
N = 20000;
varu = 1;
varv = 100;
a = 0.999;
% Generate the noisy observed signal
u = sqrt(varu)*randn(N,1);
s = 0; % Initialize s to be the mean
for n = 2:N
s(n,1) = a*s(n-1,1) + u(n);
end
v = sqrt(varv)*randn(N,1);
x = s + v;
% Step 1
M = 50;
tau = (0:(M-1))';
% Step 2
rvv = zeros(M,1);
rvv(1) = varv;
% Step 3
kk = 1;
for k = 0:M-1
rxx(kk,1) = 1/(N-k)*x(1:(N-k))'*x(kk:N);
kk = kk + 1;
end
% Step 4
rss = rxx - rvv;
% Step 5
Rxx = toeplitz(rxx);
% Step 6
rxs = rss;
% Step 7
w = inv(Rxx)*rxs;
% Step 8
for n = M:N
y(n,1) = w'*flipud(x((n-M+1):n));
end
%% Plot result
plot(x)
grid, xlabel('time index n'), ylabel('Amplitude'), hold on
plot(y)
plot(s)
legend('x(n)','y(n)','s(n)')
title('Wiener filtering')
Derivation of the Wiener filterPermalink
For the derivation of the time domain Wiener filter, check out the extra material.
Leave a comment