<<

A Straightforward Derivation of the Matched Filter

Nicholas R. Rypkema

This short manuscript is intended to provide the reader with a simple and straightforward derivation of the matched filter, which is typically used to solve the detection problem. In our case, we are interested in the use of the matched filter to determine whether or not an acoustic signal broadcast underwater is present in a measurement recorded by a hydrophone receiver, as shown in Fig. 1. It is in large part informed by Chapter 3 of the excellent reference by Wainstein and Zubakov, ‘Extraction of from ’ 1.

Template Measured Measured Spectrogram 1.5 0.05 200 1 180 0.5 160 0 0 140 -0.5 Amplitude 120

-1 100

-1.5 -0.05 Time (ms) 80 0 100 200 300 400 500 600 700 0 100 200 300 400 500 600 700 Samples (n) Samples (n) 60 15 15 40 10 10 20 5 5 Time (ms) 05 10 15 05 10 15 05 10 15 Frequency (kHz) Frequency (kHz) Frequency (kHz)

Figure 1: Ideal and measured 20 ms, 16–18 kHz linear frequency modulation (lfm) up-chirp – the ideal up-chirp is shown on the top-left over time (750 samples or 20 ms), and as a spectro- gram in the bottom-left; the corresponding in-water up-chirp as measured by a hydrophone is shown in the top-center over time, and as a spectrogram in the lower-center; the spectrogram of the full sample of measured acoustic data (8000 samples or 213 ms) is shown on the right.

Suppose that the broadcast signal s(t) (the template in Fig. 1) is present in the measure- ment x(t) (the measured signal in Fig. 1), so that:

x(t) = s(t) + n(t) (1) where n(t) is noise, which is a stationary random process. Consider a Linear Time-Invariant (LTI) filter with impulse response h(t) that takes as an input the measured signal to produce an output y(t), composed of a filtered signal term ys(t) and a filtered noise term yn(t):

1L. Wainstein, V. Zubakov, Extractions Of Signals From Noise. Englewood Cliffs, NJ: Prentice-Hall, 1962.

1 of 7 Z ∞ y(t) = x(t) ∗ h(t) = x(τ )h(t − τ)dτ (2) −∞

= (s(t) + n(t)) ∗ h(t) := ys(t) + yn(t) (3) where Z ∞ ys(t) = s(t) ∗ h(t) = s(τ)h(t − τ)dτ (4) −∞ Z ∞ yn(t) = n(t) ∗ h(t) = n(τ )h(t − τ)dτ (5) −∞

The goal is then to find a filter that will maximize the output Signal-to-Noise Ratio (SNR) at some chosen time t0. Intuitively, this can be understood as trying to detect the presence of a known signal s(t) in some measurement x(t) that includes random process noise n(t) at time t0, and doing so by using an LTI filter whose output will be much greater if the signal s(t) is present than when it is absent; to do this, the filter should make the instantaneous power in ys(t) as large as possible compared to the average power in n(t) at time t0, which is equivalent to maximizing the standard definition of the SNR. Assuming that the signal s(t) is of finite duration, we can write it as the Fourier transform:

1 Z ∞ s(t) = S(ω)ejωtdω (6) 2π −∞ where Z ∞ S(ω) = s(t)e−jωtdt (7) −∞ ω := 2πf (8)

Recall that in the time domain equals multiplication in the frequency domain:

ys(t) = s(t) ∗ h(t) (9) m

Ys(ω) = S(ω)H(ω) (10)

Thus, we can rewrite ys(t) from Eq. 4 using the inverse Fourier transform as:

Z ∞ 1 jωt ys(t) = H(ω)S(ω)e dω (11) 2π −∞

2 of 7 where H(ω) is the transfer function of the LTI filter whose impulse response is h(t). Unfor- tunately, since the noise n(t) is a random process, it is generally difficult to obtain a similar complete specification for the output yn(t) from Eq. 5 using the Fourier transform as in Eq. 11; however, from the Wiener-Khinchin theorem, we can write the average power of this noise process as:

Z ∞ 2 1 E |n(t)| = Sn(ω)dω (12) 2π −∞ where Sn(ω) is the power of the noise at the input of the filter. At the output of the LTI filter, the noise has intensity:

Z ∞ 2 1 2 E |yn(t)| = |H(ω)| Sn(ω)dω (13) 2π −∞

The SNR at time t0 can now be written in terms of Eqs. 11 and 13, as the ratio of the output power of the filtered signal to the output power of the noise:

 S  |y (t )|2 := s 0 (14) N |y (t)|2 t0 E n ∞ 2 R H(ω)S(ω)ejωt0 dω 1 −∞ := (15) 2π R ∞ 2 −∞ |H(ω)| Sn(ω)dω

Now we wish to maximize this SNR in order to determine whether or not the signal s(t) is present in the measurement x(t); in other words, we want the absolute value of ys(t0) to 2 exceed the quantity E|yn(t)| by as much as possible in order to improve our ability to detect the signal in our measurement. Consider the following form of the Cauchy-Schwarz inequality (a proof of this inequality is provided at the end of this manuscript):

Z ∞ 2 Z ∞ Z ∞ 2 2 A(ω)B(ω)dω ≤ |A(ω)| dω |B(ω)| dω (16) −∞ −∞ −∞

We can apply this inequality on the numerator of Eq. 15 to find the transfer function H(ω) of the filter we are looking for:

3 of 7 Z ∞ 2 Z ∞ Z ∞ |S(ω)|2 jωt0 2 H(ω)S(ω)e dω ≤ |H(ω)| Sn(ω)dω dω (17) −∞ −∞ −∞ Sn(ω) where S(ω) p jωt0 A(ω) = H(ω) Sn(ω)e ,B(ω) = p (18) Sn(ω)

The inequality shows that the SNR of Eq. 15 can be simplified for the following upper bound:

 S  1 Z ∞ |S(ω)|2 ≤ dω (19) N 2π S (ω) t0 −∞ n

Now, this upper bound can be exactly met if we take:

S∗(ω) H(ω) = ce−jωt0 (20) Snω)

−jωt where c is an arbitrary constant, e 0 is a simple time delay to the detection time t0, and S∗(ω) is the complex conjugate of the Fourier transformed signal S(ω) that we are trying to detect. The filter defined by Eq. 20 is thus the best LTI filter for detecting a known signal in the presence of noise. If the noise n(t) is a Gaussian random process then this filter is an absolute optimum, producing an SNR of:

 S  2 1 Z ∞ = |S(ω)|2 dω (21) N N 2π t0 0 −∞

N0 since the power spectral density of a Gaussian random noise process is 2 . The filter of Eq. 20 has a very simple and intuitive meaning: since the transfer function of the filter is proportional to the amplitude spectrum of the signal we are trying to detect, this means that the filter attempts to only ‘pass through’ the frequencies which are present in the signal [?]. This leads us finally to the matched filter. For simplicity, let us consider such that Eq. 20 simplifies to:

H(ω) = e−jωt0 S∗(ω) (22)

Since the signal s(t) is real, S∗(ω) = S(−ω), and we can write the signal output after filtering (Eq. 11) as:

4 of 7 1 Z ∞ −jωt0 jωt ys(t) = e S(−ω)S(ω)e dω (23) 2π −∞ 1 Z ∞ = S(−ω)S(ω)ejω(t−t0)dω (24) 2π −∞ using the Fourier transform of Eq. 7, we can manipulate the equation as follows:

∞  ∞  1 Z Z 0 jω(t−t0) 0 −jωt 0 ys(t) = S(−ω)e s(t )e dt dω (25) 2π −∞ −∞ ∞  ∞  Z 1 Z 0 = S(−ω)ejω(t−t0) s(t0)e−jωt dt0 dω (26) −∞ 2π −∞ swapping the order of integration:

∞  ∞  Z 1 Z 0 0 −jωt jω(t−t0) 0 ys(t) = s(t ) S(−ω)e e dω dt (27) −∞ 2π −∞ ∞  ∞  Z 1 Z 0 = s(t0) S(−ω)e−jω(t −t+t0)dω dt0 (28) −∞ 2π −∞ and using the inverse Fourier transform of Eq. 6 and the time-reversal property:

Z ∞ 0 0 0 ys(t) = s(t )s(t − t + t0)dt (29) −∞

Finally, we can use a change of variables to get:

Z ∞ 0 0 0 ys(τ) = s(t )s(t − τ)dt (30) −∞

where τ = t − t0 (31)

Recall that for a real, continuous-time signal, its is given by:

Z ∞ Rss(τ) = s(t)s(t − τ)dt (32) −∞

Comparing Eqs. 32 and 30, it is readily apparent that:

5 of 7 ys(t) = Rss(t − t0) (33)

Interestingly, the matched filter simply acts as a correlator whose output at time t0 is Rss(t − R ∞ 2 t0) = Rss(0) = −∞ s (t)dt = E (i.e. the autocorrelation function delayed to have a maximum peak at time t0). In the presence of noise n(t) in our measurement x(t), the matched filter acts as:

Z ∞ y(t) = x(τ )s(τ − t)dτ = x(t) ∗ s(−t) (34) −∞

So we see that the matched filter simply acts as a cross-correlation between the known (broad- cast) signal s(t) and the measurement x(t), and it will peak at the time in the measurement at which the known signal occurs. This is equivalent to a convolution of the measurement against a time-reversed (and conjugated if s(t) is complex) version of the known signal s(t).

For simplicity, the ‘canonical’ matched filter is set so that t0 = 0, resulting in a transfer function from Eq. 22 of H(ω) = S∗(ω). The matched filter output in the frequency domain is thus:

Y (ω) = X(ω)S∗(ω) (35)

Finally, for practical purposes, the matched filter for a discrete, digitized signal is given by:

∞ X y[n] = x[k]s[k − n] (36) k=−∞

Again, this calculation is more easily computed by taking the Discrete Fourier Transform (DFT) of the measurement and known signal and multiplying in the frequency domain:

y[n] = x[n] ∗ s[−n] ⇔ Y [ω] = X[ω]S∗[ω] (37)

To conclude, the matched filter is in essence equivalent to the cross-correlation of the measure- ment with the desired signal, which in turn is equivalent to the convolution of the measurement with the time-reversed (and conjugated) desired signal. This completes the derivation of the matched filter.

6 of 7 Proof of the Cauchy-Schwarz Inequality

Z ∞ Z ∞ ∗ 0 0 ∗ 2 0 A(ω)B (ω ) − A(ω )B (ω) dωdω −∞ −∞ Z ∞ Z ∞ = A(ω)B∗(ω0) − A(ω0)B∗(ω) A∗(ω)B(ω0) − A∗(ω0)B(ω) dωdω0 (38) −∞ −∞ Z ∞ Z ∞ = [|A(ω)|2|B(ω0)|2 + |A(ω0)|2|B(ω)|2 − A(ω)B(ω)A∗(ω0)B∗(ω0) −∞ −∞ − A(ω0)B(ω0)A∗(ω)B∗(ω)]dωdω0 ≥ 0 (39)

The ≥ is obviously true, since the original integral is nonnegative due to the ||2 operator. Now given that:

Z ∞ Z ∞ Z ∞ Z ∞ |A(ω)|2|B(ω0)|2dωdω0 = |A(ω0)|2|B(ω)|2dωdω0 (40) −∞ −∞ −∞ −∞ Z ∞ Z ∞ = |A(ω)|2dω |B(ω)|2dω (41) −∞ −∞ and:

Z ∞ Z ∞ A(ω)B(ω)A∗(ω0)B∗(ω0)dωdω0 −∞ −∞ Z ∞ Z ∞ = A(ω0)B(ω0)A∗(ω)B∗(ω)dωdω0 (42) −∞ −∞ Z ∞ Z ∞ = A(ω)B(ω)dω A∗(ω)B∗(ω)dω (43) −∞ −∞ Z ∞ 2

= A(ω)B(ω)dω (44) −∞ we obtain the inequality:

Z ∞ 2 Z ∞ Z ∞ 2 2 A(ω)B(ω)dω ≤ |A(ω)| dω |B(ω)| dω (45) −∞ −∞ −∞

7 of 7