4
$\begingroup$

I am very new to signal processing, and a bit confused with the matched filter. Assume that I have a time series and a specific waveform I need to identify in it. By definition:

a matched filter is obtained by correlating a known signal, or template, with an unknown signal to detect the presence of the template in the unknown signal.

So I take the window from the sequence, generate the test signal with the same sampling rate, cross-correlate them, find the maximum and threshold it. Is cross-correlating my measured time sequence with the generated waveform a matched filter (for example, using xcorr in matlab), or there is a specific procedure I must follow to produce a "more correct" matched filter. Thank you.

$\endgroup$
1
  • 1
    $\begingroup$ Yes it is a matched filter, no you don't need to do anything else. The implementation is that simple. $\endgroup$
    – MBaz
    Commented Feb 27, 2019 at 16:17

1 Answer 1

7
$\begingroup$

I'll illustrate with an example: detecting a rectangular pulse in noise, in Matlab.

Let's start with defining the signal that contains the pulse.

fs = 1/1000;
t = 0:fs:1;
s = [zeros(1,400), ones(1,100), zeros(1,501)];

First let's do detection in noise with small power. We calculate the received (noisy) signal:

np = 0.1;  % noise power (variance)
n = sqrt(np)*randn(1,1001); % noise signal
r = s + n; % received signal
plot(t,r); title('Received signal, small noise power');

enter image description here

Now let's run the correlation:

c = xcorr(r,s);
plot(c); title('Correlation, small noise power');

enter image description here

You can see how the correlation produced a large output, indicating that the pulse was there. What is amazing is that the correlator can find the pulse even when it is impossible for one to see it. Let us increase the noise power and repeat the process.

np = 4;
n = sqrt(np)*randn(1,1001);
r1 = s + n;  % received signal with large noise

enter image description here

enter image description here

As you can see, the correlator has an incredible ability to detect signals that are embedded in strong noise.

One thing you can do for yourself is run the correlation when the pulse is not present. The signal will be hard to distinguish from the noisy pulse shown above, but you'll see that the correlation does not produce a sharp maximum.

So, the implementation is quite easy; what is not so easy to do is:

  • Prove that this technique produces the best possible signal to noise ratio at the correlation's peak.
  • Determine the optimum threshold given some desired constraints on the probability of wrong detection (false positive or false negative).
$\endgroup$
4
  • $\begingroup$ Thank you for the explanation! I've already been using this technique for some time, just got confused with the whole terminology. What also got me confused is this tutorial from LIGO link, where they use power spectrum density when computing cross-correlation with fft. $\endgroup$ Commented Feb 28, 2019 at 11:53
  • $\begingroup$ @DmitryFrolov That's a nice tutorial and illustrates how to improve the SNR in the case where the noise is not frequency flat. In most communications and DSP applications, the noise is flat, and that's what I assumed in my answer. $\endgroup$
    – MBaz
    Commented Feb 28, 2019 at 15:16
  • $\begingroup$ Could you then kindly suggest a paper or overview of methods for impoving the matched filter SNR? Are those need to be determined heuristically, or there are formal criteria for choosing one? Is the matched filter useful in situations when the noise is not stochastic, but correlated with processes with frequiencies of magnitude close to that of a template, e.g. the signal is modulated (assume that the signa cannot be demodulated)? Oh, too many questions! $\endgroup$ Commented Feb 28, 2019 at 16:44
  • 1
    $\begingroup$ Most of my work is related to Gaussian flat noise... however, there are many books with titles similar to "detection of signals in noise" that cover this subject. The one by McDonough is sort of the classic reference but is a bit heavy on the math. $\endgroup$
    – MBaz
    Commented Feb 28, 2019 at 17:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.