C911 of 55
0 XP
  1. Hook
  2. Play
  3. Predict
  4. Name it
  5. Check
  6. Explain

C9 · Lesson 11 · Correlation and matched filtering

Finding a known pattern, and how late it arrived

A radar sends a pulse and listens for its echo, buried in noise and delayed by the trip to the target and back. A GPS receiver finds the code of each satellite and measures its delay to a few nanoseconds. A phone's two microphones find which way a voice comes from. All three slide a known pattern along a received signal and ask, at each shift, how well the two match. That operation, correlation, is convolution with one signal reversed, and the best possible detector of a known pulse in noise is built from it.

  • The stems are a 7-sample pattern, a Barker code: + + + − − + −. The second set is the same pattern shifted by L samples.
  • The readout multiplies the two sample by sample and adds: the correlation at lag L.
  • Slide L. At L = 0 every product is +1 and the sum is 7. At every other lag the sum is 0 or −1: the pattern matches itself only when it's lined up.

Predict

A pulse of 7 samples, each +1, is correlated with itself. What is the largest correlation at any lag other than 0?

Name it

Correlation

The cross-correlation of x and y measures their match at each lag k:

rxy[k]=∑nx[n+k]y[n],rxy(τ)=∫x(t+τ)y(t)dt

It's a convolution with y reversed: rxy[k]=x[k]*y[−k]. The autocorrelation rxx is a signal correlated with itself. Its value at lag 0 is the signal's energy, and no other lag is larger:

|rxy[k]|≤ExEy

Dividing by ExEy gives the correlation coefficient, between −1 and 1.

Finding a delay

If y is a copy of x delayed by D samples (plus noise), ryx[k] peaks at k = D. At a sample rate fs that's a time delay D/fs. Two microphones a distance d apart hear a source at angle θ from broadside with a delay dsin⁡θ/c.

The matched filter

To detect a known pulse s[n] in white noise of variance σ2 per sample, filter with its reversed copy, h[n]=s[N−1−n]. The output at the end of the pulse is the pulse's energy E, while the noise there has variance σ2E. So the peak signal-to-noise ratio is

SNRout=Eσ2

and no other linear filter does better. For N samples of amplitude A, E = NA², a gain of N over the per-sample SNR: 10log10⁡N dB. A longer pulse gives more energy at the same peak power, which is why radars and GPS use long coded pulses.

Worked example

Find the autocorrelation of x = [1, 2, 3].

Show the solution
  1. Lag 0. This is the energy: r[0]=1+4+9=14
  2. Lag ±1. r[±1]=1⋅2+2⋅3=8
  3. Lag ±2. r[±2]=1⋅3=3
  4. Collect. So r = [3, 8, 14, 8, 3] for lags −2 to 2: symmetric, as every autocorrelation is, and largest at 0.

Answer r = [3, 8, 14, 8, 3] for lags −2 to 2.

Worked example

Two microphones 0.5 m apart, sampling at 48 kHz, see a correlation peak at a lag of 20 samples. From what angle does the sound come?

Show the solution
  1. Delay. Δt=20/48000s=0.417ms
  2. Path difference. d=343×0.000417m=0.143m
  3. Angle. sin⁡θ=0.143/0.5=0.286θ=16.6° measured from broadside.
  4. Resolution. One sample of lag is 0.71 cm of path, so the angle can be read to about a degree near broadside, which is why such arrays interpolate the peak between samples.

Answer the sound comes from 16.6° off broadside.

Worked example

A radar pulse is a 13-chip Barker code of amplitude 1, in noise of standard deviation 1 per sample. What does the matched filter do for the signal-to-noise ratio?

Show the solution
  1. SNR per sample. Per sample the SNR is 1, 0 dB, so a single sample tells almost nothing.
  2. Matched-filter peak. The pulse's energy is 13, so the matched filter's peak SNR is 13, a gain of 13: 10log10⁡13=11.1dB
  3. Side lobes. The code's correlation side lobes are at most 1, against a peak of 13: 20log10⁡(1/13)=−22.3dB so a large target's side lobes don't hide a small one nearby.

Answer the matched filter raises the SNR from 1 (0 dB) per sample to 13 (11.1 dB) at its peak, a gain of 13, with side lobes 22.3 dB down.

Check

Find the autocorrelation of x = [2, 3, 4].

(a)

What is it at lag 0?

(b)

And at lag 1?

Check

Microphones 0.5 m apart, sampling at 16 kHz, see a correlation peak at 4 samples. Sound travels 343 m/s.

(a)

What is the delay?

Write units the way you normally would: 1.5 ms, 1500 µs and 0.0015 s are the same answer.

(b)

From what angle off broadside does the sound come?

Check

A known pulse of 13 samples arrives with a per-sample SNR of −10 dB.

(a)

What gain does the matched filter give?

(b)

What is the peak SNR at its output?

Check

Signals with energies Ex = E and Ey = F have correlation coefficient c at some lag.

Step 1

What is the correlation there?

Type it the way you would write it, like 3sin(2πft) or 3*sin(2*pi*f*t). Angles can be in radians or carry a degree sign, like 45°.

Check

How is the cross-correlation rxy[k] related to convolution?

Check

A Barker code of length 11 has a correlation peak of 11 and side lobes no larger than 1.

(a)

How far below the peak are the side lobes?

(b)

For a plain pulse of 11 ones, how far below the peak is the correlation at lag 1?

Check

Write find_delay(x, y): the lag k (0 ≤ k < len(y)) at which y best matches x shifted, that is, where ∑ny[n+k]x[n] is largest.

Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.

Explain why

Why does a long coded pulse let a radar see small targets without a high peak power?

Practice

Keep practicing

7 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.