A Straightforward Derivation of the Matched Filter
Total Page:16
File Type:pdf, Size:1020Kb
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 signal 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 Signals from Noise' 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 1 y(t) = x(t) ∗ h(t) = x(τ )h(t − τ)dτ (2) −∞ = (s(t) + n(t)) ∗ h(t) := ys(t) + yn(t) (3) where Z 1 ys(t) = s(t) ∗ h(t) = s(τ)h(t − τ)dτ (4) −∞ Z 1 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 1 s(t) = S(!)ej!td! (6) 2π −∞ where Z 1 S(!) = s(t)e−j!tdt (7) −∞ ! := 2πf (8) Recall that convolution 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 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 1 2 1 E jn(t)j = Sn(!)d! (12) 2π −∞ where Sn(!) is the power spectral density of the noise at the input of the filter. At the output of the LTI filter, the noise has intensity: Z 1 2 1 2 E jyn(t)j = jH(!)j 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 jy (t )j2 := s 0 (14) N jy (t)j2 t0 E n 1 2 R H(!)S(!)ej!t0 d! 1 −∞ := (15) 2π R 1 2 −∞ jH(!)j 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 Ejyn(t)j 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 1 2 Z 1 Z 1 2 2 A(!)B(!)d! ≤ jA(!)j d! jB(!)j 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 1 2 Z 1 Z 1 jS(!)j2 j!t0 2 H(!)S(!)e d! ≤ jH(!)j 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 1 jS(!)j2 ≤ 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 1 = jS(!)j2 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 white noise 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 1 −j!t0 j!t ys(t) = e S(−!)S(!)e d! (23) 2π −∞ 1 Z 1 = S(−!)S(!)ej!(t−t0)d! (24) 2π −∞ using the Fourier transform of Eq. 7, we can manipulate the equation as follows: 1 1 1 Z Z 0 j!(t−t0) 0 −j!t 0 ys(t) = S(−!)e s(t )e dt d! (25) 2π −∞ −∞ 1 1 Z 1 Z 0 = S(−!)ej!(t−t0) s(t0)e−j!t dt0 d! (26) −∞ 2π −∞ swapping the order of integration: 1 1 Z 1 Z 0 0 −j!t j!(t−t0) 0 ys(t) = s(t ) S(−!)e e d! dt (27) −∞ 2π −∞ 1 1 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 1 0 0 0 ys(t) = s(t )s(t − t + t0)dt (29) −∞ Finally, we can use a change of variables to get: Z 1 0 0 0 ys(τ) = s(t )s(t − τ)dt (30) −∞ where τ = t − t0 (31) Recall that for a real, continuous-time signal, its autocorrelation is given by: Z 1 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 1 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 1 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.