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,,wM1]TRM and x(n)=[x(n),x(n1),x(nM+1)]TRM such that the LMMSE estimate of s(n) given x(n) is:

ˆs(n)=wTx(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=ˆR1xxˆrxs,

where ˆRxxRM×M is the sample estimate of the autocorrelation matrix of x(n) and ˆrxsRM is the sample estimate of the cross-correlation vector between s(n) and x(n).

4) Step-by-step guidePermalink

  1. Set filter length e.g. M=20.
  2. Set autocorrelation of the noise to

    rvv(k)=σ2vδ(k),for k=0,,M1

    where δ(k) is the Kronecker delta function and k is the lag-index.

  3. Compute the unbiased sample estimate of the autocorrelation of x(n)

    ˆrxx(k)=1NkNk1n=0x(n)x(n+k),for k=0,...,M1

    or equivalently

    ˆrxx(k)=1NkxT(n)x(n+k),for k=0,...,M1

    where x(n)=[x(0),...,x(Nk1)]T and x(n+k)=[x(k),...,x(N1)]T.

  4. Estimate the autocorrelation of s(n) as

    ˆrss(k)=ˆrxx(k)rvv(k)
  5. Form the autocorrelation matrix ˆRxx of x(n)
  6. Form the cross-correlation vector between x(n) and s(n)

    ˆrxs(k)=ˆrss(k)
  7. Compute the Wiener filter coefficients

    w=ˆR1xxˆrxs
  8. Perform filtering

    ˆs(n)=wTx(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