Transcript 08filled

BIEN425 – Lecture 8
• By the end of the lecture, you should be able to:
–
–
–
–
Compute cross- /auto-correlation using matrix multiplication
Compute cross- /auto-correlation using DFT and Matlab
Relate auto-correlation of white noise with its average power
Extract periodic signal from noise
1
Recall: Convolution
• Is a filter operation that computes the zero-state output
corresponding to an input x(k)
• Matlab code: conv.m
k
y (k )  h(k ) * x(k )   h(i ) x(k  i )
i 0
• As denoted by *
• If h(i) is a L-point signal, and x(k) is a M-point signal
then the convolution has length L+M-1
2
Circular convolution
• Let h(k) and x(k) be N-point signals and xp(k) be the
periodic extension of x(k). Circular convolution is
defined as
N 1
h(k )  x(k )   h(i ) x p (k  i )
i 0
• Very simply yc(k) = C(x)h, where C(x) is defined as:
 x(0) x( N  1) x( N  2)
 x(1)
x(0)
x( N  1)
C ( x)  
x(1)
x(0)
 x(2)
 








3
• Note that circular convolution is more efficient (faster)
• However, it cannot be used directly to compute zerostate response
• Also needs to assume h(k) and x(k) have the same length.
• Another problem is with periodicity
yc ( k  N )  yc ( k )
But the zero-state response is not periodic
• We can solve this using zero-padding.
4
Zero padding
• Pad both h(k) and x(k) to be length N = L+M-1, now
denoted as hz(k) and xz(k)
hz (k )  [h(0) h( L  1),0,0,]T
xz (k )  [ x(0) x( M  1),0,0,]T
• Now, y = C(xz)hz
y is now M+L-1 in length
5
Example
• Matlab example
6
Fast convolution
• Convolution in the time domain maps into
multiplication in the frequency domain using Ztransform.
Z{ y(k )}  H ( z) X ( z)
• We may substitute circular for linear convolution; DFT
for Z-transform
DFT{h(k )  x(k )}  H (i) X (i)
7
• Now if enough zeros are padded to h(k) and x(k) so that
they both have length N≥L+M-1 where N = 2r
We get Hz(i) and Xz(i)
• This is called fast linear convolution
y(k )  IFFT{H z (i) X z (i)}
h(k)
Zero pad
hz(k)
FFT
y(k)
IFFT
x(k)
Zero pad
xz(k)
FFT
8
Cross-correlation
• Measures the degree to which a pattern of L-point signal
y(k) is similar to the pattern of an M-point signal x(k)
For example: on next slide
• This definition works fine for deterministic signals.
1 L1
rxy (k )   x(i ) y (i  k )
L i 0
• To generalize it to include stochastic signals:
rxy (k )   [ x(i ) y (i  k )]
9
10
• Again, it can be computed using matrix formulation:
rxy  D( y ) x
 y ( 0)
 0

 0
1
C ( y) 
L




y (1)
y ( 0)
0


y ( M  1)
y (1) y ( M  2)
y ( 0)

0
 0
y ( M  1) 0 0








• Example 4.8, the index corresponding to the largest rxy(k)
represents the optimal delay.
11
This shows optimal delay for y is 3 samples
12
Normalized linear cross-correlation
• So that it takes on values [-1, 1]
Pxy (k ) 
rxy (k )
M
L
rxx (0)ryy (0)
This allows us to measure the amount of “significance”
that is independent on the scaling or amplitude of the
signal
13
We can have a fixed threshold to determine if two signals
are significantly similar.
14
Fast correlation
• Again, similar to fast convolution, we could utilize
properties of FFT to achieve a fast version of correlation
IFFT { X z (i )Yz* (i )}
rxy (k ) 
L
• Block diagram:
x(k)
Zero pad
xz(k)
FFT
rxy(k)
IFFT /L
y(k)
Zero pad
yz(k)
FFT *
15
Auto-correlation
• For special case where y(k) = x(k)
1 N 1
rxx (k )   x(i ) x(i  k )
N i 0
• It can be expressed in terms of expected values
rxx (k )   [ x(i ) x(i  k )]
rxx (0)  Px
• For the special case of white noise v(k),
 0, k  0
rvv (k )  
 Pv , k  0
16
Relating auto-correlation and PSD
If we apply the same principle of circular convolution to
correlation, circular-correlation cxy(k) can be obtained
DFT {cxx (k )}  DFT { N1 x(k )  x(k )}
Notice here (–k)
1
*
DFT {cxx (k )}  X (i ) X (i )  S N (i )
N
17
Extracting periodic signals from noise
Motivation?
• Let’s say y(k) = x(k) + v(k), 0≤ k <N and the period M<N.
x(k) is periodic M (but we didn’t know that from the beginning
c yy (k )   { y (i ) y p (i  k )}
c yy (k )  cxx (k )  Pv (k )
Because correlation of noise with
any other signal is 0!
• Therefore, for k≠0, cyy(k) = cxx(k)
18
• Auto-correlation averages the noise out!
• Also note that cxx(k) is periodic
c xx (k  M )  c xx (k )
• Therefore, the period of x(k) can be estimated by
examining the peaks and valleys in cyy(k)
19
• Once the period of a noise-corrupted signal is
determined, we can estimate the original periodic signal
• Let L = floor (N/M)
• We define delta function of period M
L 1
 M (k )    (k  iM )
0≤k<M
i 0
c y M (k )  c M y ( k )
By definition
1 N 1
c y M (k )    M (i ) y p (i  k )
N i 0
1 L1
c y M (k )   y p (qM  k )
N q 0
Because L = floor of (N/M)
20
1 L1
1 L1
c y M (k )   x p (qM  k )   v p (qM  k )
N q 0
N q 0
1 L1
1 L1
c y M (k )   x(k )   v p (qM  k )
N q 0
N q 0
Because x is period M
L
1 L1
c y M (k )  x(k )   v p (qM  k )
N
N q 0
• Now the second term approaches 0 for large L
• Therefore
N
xˆ (k )  c y M (k )
L
21
Block diagram
(k)
v(k)
x(k)
y(k)
Circular
cross
correlation
c y M (k )
N/L
xˆ (k )
22