Correlated and Uncorrelated Signals Problem: we have two signals x[n] and y[n] . How “close” are they to each other? Example: in a radar (or sonar) we transmit a pulse and we expect a return 1 0.8 0.6 Transmit 0.4 0.2 0 -0.2 -0.4 -0.6 -0.8 -1 0 2 4 6 8 10 12 14 16 18 20 1.5 1 0.5 Receive 0 -0.5 -1 -1.5 -2 0 20 40 60 80 100 120 140 160 180 Example: Radar Return Since we know what we are looking for, we keep comparing what we receive with what we sent. 1 1 0.8 0.8 0.6 0.6 0.4 0.4 0.2 0.2 0 0 -0.2 -0.2 -0.4 -0.4 -0.6 -0.6 -0.8 -0.8 -1 0 2 4 6 8 10 12 14 16 18 20 -1 0 2 4 6 8 10 12 14 16 18 20 1.5 1 0.5 0 Receive -0.5 -1 -1.5 -2 0 Similar? 20 NO! 40 60 80 100 120 140 Think so! 160 180 Inner Product between two Signals We need a “measure” of how close two signals are to each other. This leads to the concepts of • Inner Product • Correlation Coefficient Inner Product Problem: we have two signals x[n] and y[n] . How “close” are they to each other? Define: Inner Product between two signals of the same length N 1 rxy x[n] y *[n] n 0 Properties: N 1 N 1 rxx x[n]x [n] x[n] 0 * n 0 2 n 0 2 rxy rxx ryy 2 rxy rxx ryy if and only if y[n] C x[n] for some constant C How we measure similarity (correlation coefficient) Assume: zero mean Compute: xy | rxy | rxx ryy Check the value: 0 xy 1 xy 0 x,y uncorrelated xy 1 x,y strongly correlated Back to the Example: with no return x[n] x[n] y[n] y[n] 2 3 3 2 2 1.5 1 0.5 1 0 0 1 0 -0.5 -1 -1 -1 -2 -2 -1.5 -3 -2 -3 0 100 200 300 400 500 600 700 800 900 0 100 200 300 400 500 600 700 800 0 100 200 300 400 500 600 700 800 900 1000 900 rxy 2.27 rxx 500 ryy 982 xy 0.003 NO Correlation! Back to the Example: with return x[n] x[n] y[n] y[n] 2 2.5 3 1.5 2 2 1 1.5 0 1 1 0.5 0 -0.5 -1 0.5 -1 -1.5 -2 0 -2 0 100 200 300 400 500 600 700 800 900 -3 0 100 200 300 400 500 600 700 800 900 -0.5 0 100 200 300 400 500 600 700 800 900 rxy 494 rxx 500 ryy 754 0.8 Good Correlation! 1000 Inner Product in Matlab Take two signals of the same length. Each one is a vector: x x(1) x(2) x( N ) Row vector y y(1) Row vector y(2) y( N ) Define: Inner Product between two vectors y * (1) * N y ( 2) * rxy x(n) y (n) x(1) x(2) x( N ) n 1 x * y ( N ) rxy x * y' y' conjugate, transpose Example Take two signals: y 2.5 x 2 3 2 1.5 1 1 0.5 0 0 -0.5 -1 -1 -1.5 -2 -2 -2.5 0 50 100 150 200 Compute these: rxy x * y' 19.7 rxx x * x' 218.8 ryy y * y' 241.9 250 300 -3 0 50 100 150 200 250 300 Then: xy 19.7 0.0856 0 218.8 241.9 x,y are not correlated Example Take two signals: Compute these: 3 x rxy x * y' 230.9 2 1 rxx x * x' 229.6 0 -1 ryy y * y' 234.3 -2 -3 y 0 50 100 150 200 250 300 Then: 3 2 xy 1 230.9 0.9955 1 229.6 234.3 0 -1 x,y are strongly correlated -2 -3 0 50 100 150 200 250 300 Example Take two signals: y 3 x 3 2 2 1 1 0 0 -1 -1 -2 -2 -3 0 50 100 150 200 Compute these: rxy x * y' 230.9 rxx x * x' 229.6 ryy y * y' 234.3 250 300 -3 0 50 100 150 200 250 300 Then: 230.9 xy 0.9955 1 229.6 234.3 x,y are strongly correlated Typical Application: Radar Send a Pulse… s[n] n N … and receive it back with noise, distortion … y[n] n n0 Problem: estimate the time delay n0 , ie detect when we receive it. Use Inner Product “Slide” the pulse s[n] over the received signal and see when the inner product is maximum: N 1 rys [n] y[n ]s *[] rys[n] 0, if n n0 0 n y[] n0 s[] N Use Inner Product “Slide” the pulse x[n] over the received signal and see when the inner product is maximum: N 1 rys [n] y[n ]s*[] MAX 0 y[] n0 s[] N if n n0 Matched Filter Take the expression N 1 rys [n] y[n ]s*[] n 0 s*[ N 1] y[n N 1] ... s*[1] y[n 1] s*[0] y[n] Compare this, with the output of the following FIR Filter rˆ[n] h[0] y[n] ... h[1] y[n 1] h[ N 1] y[n N 1] Then y[n] h[n] rˆ[n] rys[n N 1] h[n] s*[ N 1 n], n 0,...,N 1 Matched Filter This Filter is called a Matched Filter y[n] rˆ[n] h[n] h[n] s*[ N 1 n], n 0,...,N 1 The output is maximum when n N 1 n0 i.e. n n0 N 1 rˆ[n] rys[n N 1] Example We transmit the pulse s[n], n 0,...,N 1 shown below, with length N 20 1 0.8 0.6 0.4 s[n] 0.2 0 -0.2 -0.4 -0.6 -0.8 -1 0 2 4 6 8 10 12 14 16 18 Max at n=119 20 n0 119 20 1 100 Received signal: 12 y[n] 1.5 rˆ[n] 1 y[n] 0.5 0 8 6 h[n] -0.5 10 4 2 0 -1 -2 -1.5 -4 -2 0 20 40 60 80 100 120 140 160 180 -6 0 20 40 h[n] s*[ N 1 n], n 0,...,N 1 60 80 100 120 140 160 180 200 How do we choose a “good pulse” We transmit the pulse s[n], n 0,...,N 1 and we receive (ignore the noise for the time being) y[n] As[n n0 ] rˆ[n] h[n] rˆ[n] rys[n N 1] h[n] s*[ N 1 n], n 0,...,N 1 where N 1 rys [n] A s[n n0 ]s*[] n 0 A rss [n n0 ] N 1 The term rss [n] s[n ]s*[] 0 is called the “autocorrelation of s[n]”. This characterizes the pulse. Example: a square pulse rss [n] N s[n] 1 0 N 1 N n N n N 1 rss [n] s[n ]s*[] ? 0 N 1 N 1 rss [0] s[]s [] s[] N 2 * 0 N 2 See a few values: 0 N 2 rss [1] s[1 ]s [] 1 N 1 * 0 rss [k ] 0 N 1 k rss [k ] N 1 k s[k ]s [] 1 N k * 0 N 1 k 0 N 1 * s [ k ] s [] 1 N k 0 k Compute it in Matlab s[n] 20 1 18 0 N 1 16 n 14 12 10 N=20; % data length s=ones(1,N); % square pulse 8 6 4 2 rss=xcorr(s); % autocorr n=-N+1:N-1; % indices for plot stem(n,rss) % plot 0 -20 -15 -10 -5 0 5 10 15 20 Example: Sinusoid 25 1 20 0.8 15 0.6 0.4 10 0.2 0 5 -0.2 -0.4 0 -0.6 -5 -0.8 -1 0 5 10 15 20 25 30 35 40 45 50 -10 -15 s[n], n 0,...,49 -20 -50 -40 -30 -20 -10 0 10 20 30 rss [n], n 49,...,49 40 50 Example: Chirp 30 1 25 0.8 0.6 20 0.4 15 0.2 0 10 -0.2 5 -0.4 -0.6 0 -0.8 -1 -5 0 5 10 15 20 25 30 35 40 45 50 -10 -50 s[n], n 0,...,49 s=chirp(0:49,0,49,0.1) -40 -30 -20 -10 0 10 20 30 rss [n], n 49,...,49 40 50 Example: Pseudo Noise 50 2.5 40 2 1.5 30 1 0.5 20 0 -0.5 10 -1 -1.5 0 -2 -2.5 0 5 10 15 20 25 30 35 40 45 50 -10 -20 -50 -40 -30 -20 -10 0 10 20 s[n], n 0,...,49 s=randn(1,50) rss [n], n 49,...,49 30 40 50 Compare them chirp cos pseudonoise 1 s[n] 2.5 1 0.8 2 0.8 0.6 1.5 0.6 0.4 1 0.4 0.2 0.2 0.5 0 0 0 -0.2 -0.2 -0.4 -0.4 -0.6 -0.6 -0.5 -1 -1.5 -0.8 -1 -0.8 -2 0 5 10 15 20 25 30 35 40 45 -1 50 0 5 10 15 20 25 30 35 40 45 50 -2.5 30 rss [n] 0 5 10 15 20 25 30 35 0 10 20 40 45 50 50 25 25 20 15 20 10 15 40 30 20 5 10 0 5 10 0 0 -5 -10 -5 -15 -20 -50 -10 -40 -30 -20 -10 0 10 20 30 40 50 -10 -50 -40 -30 -20 -10 0 10 20 30 40 50 -20 -50 -40 Two best! -30 -20 -10 30 40 50 Detection with Noise Now see with added noise y[n] As[n n0 ] w[n] h[n] rˆ[n] rys[n n0 N 1] ryw[n] h[n] s*[ N 1 n], n 0,...,N 1 White Noise A first approximation of a disturbance is by “White Noise”. White noise is such that any two different samples are uncorrelated with each other: 3 w[n] 2 1 0 -1 -2 -3 -4 0 100 200 300 400 500 600 700 800 900 1000 White Noise The autocorrelation of a white noise signal tends to be a “delta” function, ie it is always zero, apart from when n=0. rss [n] n White Noise and Filters The output of a Filter N 1 w[n] h[]w[n ] w[n] 0 h[n] 1 M M 1 N 1 N 1 h[ 1 ]h[ 2 ]w[n 1 ]w[n 2 ] n 0 1 0 2 0 N 1 N 1 1 M 1 h[ 1 ]h[ 2 ] w[n 1 ]w[n 2 ] 1 0 2 0 M n 0 1 w[ n ] M n 0 2 M 1 N 1 2 1 h[] 0 M w[n] n 0 M 1 2 White Noise The output of a Filter N w[n] h[]w[n ] w[n] 0 h[n] In other words the Power of the Noise at the ouput is related to the Power of the Noise at the input as N 1 2 PW h[n] Pw n 0 Back to the Match Filter rˆ[n] Arss [n n0 N 1] w[n] y[n] As[n n0 ] w[n] h[n] h[n] s*[ N 1 n], n 0,...,N 1 At the peak: rˆ[n0 N 1] Arss [0] w[n0 N 1] Match Filter and SNR At the peak: rˆ[n0 N 1] Arss [0] rsw [n0 N 1] N 1 N 1 2 Arss [0] | As[n] | | s[n] |2 n 0 n0 2 N 1 2 PW | s[n] | PW n 0 N 1 2 N PS s[n] n 0 N SNR SNRpeak N 1 2 s[n] PW n 0 Example Transmit a Chirp of length N=50 samples, with SNR=0dB 2 30 1.5 25 20 1 15 0.5 10 0 5 -0.5 0 -1 -5 -1.5 -10 -2 -15 0 50 100 150 200 Transmitted 250 300 0 200 400 600 800 1000 Detected with Matched Filter 1200 Example Transmit a Chirp of length N=100 samples, with SNR=0dB 50 2 40 1.5 30 1 0.5 20 0 10 -0.5 0 -1 -1.5 -2 -10 0 50 100 150 200 250 Transmitted 300 -20 0 200 400 600 800 1000 Detected with Matched Filter 1200 Example Transmit a Chirp of length N=300 samples, with SNR=0dB 160 2 140 1.5 120 1 100 0.5 80 0 60 -0.5 40 -1 20 -1.5 0 -2 0 50 100 150 200 250 300 -20 -40 Transmitted 0 200 400 600 800 1000 Detected with Matched Filter 1200 1400