The matched filter: best SNR in white noise
About this lesson
A receiver knows the shape of the pulse it is waiting for, but white noise is added to every sample on the way. Which filter, read once, gives the biggest signal-to-noise ratio? Follow one pulse p = 2, 2, 2, 2, 1, 1, 1, 1 mV through noise of RMS 1 mV: one sample gives SNR 4, a plain sum 18, and the matched filter, the pulse flipped in time, gives E/σ² = 20. The Cauchy–Schwarz inequality shows nothing does better. It uses convolution and correlation, and the white-noise PSD from the lesson on power spectral density; it follows the lesson on the Nyquist pulse and raised cosine.
A known pulse is sent
To send a 1, the transmitter puts out a pulse whose shape the receiver knows in advance: p = 2, 2, 2, 2, 1, 1, 1, 1 mV, one value per sample. Its energy is the sum of squares: E = 20 mV².
pulse p[k] = 2, 2, 2, 2, 1, 1, 1, 1 (mV)
k = 0 .. 7, L = 8 samples
energy E = Σ p[k]²
= 4 × 2² + 4 × 1²
= 20 mV²
polar bits: 1 -> +p, 0 -> −p
(line coding, from earlier in this module)Read the lesson step by step
A known pulse is sent
To send a 1, the transmitter puts out a pulse whose shape the receiver knows in advance: p = 2, 2, 2, 2, 1, 1, 1, 1 mV, one value per sample. Its energy is the sum of squares: E = 20 mV².
pulse p[k] = 2, 2, 2, 2, 1, 1, 1, 1 (mV) k = 0 .. 7, L = 8 samples energy E = Σ p[k]² = 4 × 2² + 4 × 1² = 20 mV² polar bits: 1 -> +p, 0 -> −p (line coding, from earlier in this module)White noise is added
On the way, random noise w[n] adds to every sample: r[n] = p[n − 8] + w[n]. It is white: equal power at every frequency, so samples are unrelated. Here its RMS is σ = 1 mV.
r[n] = p[n − 8] + w[n], n = 0 .. 31 w[n]: Gaussian, mean 0, RMS σ = 1 mV white: flat power spectral density (PSD), so w[n] and w[m] are uncorrelated (n ≠ m) the plot shows one random draw (see "Power spectral density and white noise")One sample is a gamble
Read one sample of the pulse, say r[8] = 2.31 mV. Its signal is 2 mV, its noise RMS 1 mV, so the signal-to-noise ratio (SNR) is 2²/1² = 4. With polar bits that is 2.3 % wrong bits.
SNR = signal power / noise power = 2² / σ² = 4 / 1 = 4 (6.0 dB) this draw: r[8] = 2 + w[8] = 2.31 mV polar bits, threshold 0: P(error) = Q(√SNR) = Q(2) = 0.0228 ≈ 2.3 % (1 bit in 44) Q(x) = chance a standard normal exceeds xFilter first, then sample once
Better: pass r through a filter h, then read its output y once, at time T. The pulse parts add in step, but the independent noise parts add only in power. Which h gives the biggest SNR at T?
y[n] = Σ_k h[k]·r[n − k] (convolution) at n = T: signal = Σ_k h[k]·p[T − 8 − k] noise power = σ²·Σ_k h[k]² (independent parts: powers add) SNR(h) = (Σ h·p)² / (σ²·Σ h²)The matched filter: the pulse flipped
The matched filter is the pulse flipped in time: h = 1, 1, 1, 1, 2, 2, 2, 2. Convolution flips h back, so its output compares r with the pulse itself, lined up so the window ends at n.
h[k] = p[L − 1 − k] = 1, 1, 1, 1, 2, 2, 2, 2 y[n] = Σ_k h[k]·r[n − k] = Σ_j p[j]·r[n − 7 + j] = slide the pulse along r, multiply, add (a correlation with the pulse)Slide, multiply, add
Watch the window slide along r. At each n the filter multiplies the samples under the window by the pulse and adds them up. Where the window misses the pulse, only noise is summed, so y stays small.
for every n: y[n] = Σ_j p[j]·r[n − 7 + j] window off the pulse: y = sum of noise only window on the pulse: the pulse parts add up the output is drawn as the window movesThe peak: full overlap at T
At T = 15 the window covers the whole pulse, and the signal part peaks at Σ p² = E = 20. The noise there has RMS √20 = 4.47. So SNR = E²/E = E/σ² = 20, or 13.0 dB.
T = n0 + L − 1 = 8 + 8 − 1 = 15 signal part Σ h[k]·p[7 − k] = Σ p² = 20 noise power σ²·Σ h² = 1 × 20 = 20 RMS 4.47 SNR = 20² / 20 = E/σ² = 20 (13.0 dB) this draw: y[15] = 20 + (−0.12) = 19.88No filter beats it
One sample gives SNR 4; a plain sum gives 18; the matched filter gives 20. The Cauchy–Schwarz inequality proves nothing beats E/σ², reached only when h has the pulse's shape. Only the energy matters.
filter at T SNR dB one sample h = 1 4 6.0 plain sum h = 1×8 18 12.6 matched h = p flip 20 13.0 Cauchy–Schwarz: (Σ h·p)² ≤ Σh²·Σp² => SNR ≤ Σp²/σ² = E/σ² equal only when h ∝ the flipped pulse continuous time: SNR_max = 2E/N0Decide the bit
The sampler reads y[15] = 19.88 and compares it with 0: positive, so the bit is 1. With polar bits, errors now happen with probability Q(√20) = Q(4.47): about 3.9 in a million, not 2.3 %.
decision: y[T] > 0 -> 1, y[T] < 0 -> 0 this draw: y[15] = 19.88 -> 1 P(error) = Q(√SNR) one sample Q(2) = 2.28e-2 matched Q(4.47) = 3.87e-6 with raised-cosine pulses, a root-raised- cosine at each end gives zero ISI and this same best SNRA matched filter in Python
In Python with numpy: p[::-1] flips the pulse, np.convolve runs the filter, and y[15] is the sample at T. The noise comes from a random generator, so each run's y[15] differs, but its average is 20.
import numpy as np rng = np.random.default_rng() p = np.repeat([2, 1], 4) h = p[::-1] # flip r = rng.normal(0, 1, 32) r[8:16] += p y = np.convolve(r, h) bit = int(y[15] > 0) >>> int(np.convolve(p, p[::-1])[7]) # no noise 20 rng.normal(0, 1, 32): mean 0, RMS 1 (Python 3 with numpy)
5 quick questions
Choose one answer per question. You can change your choices before checking them.
01A pulse is p = 3, 1, 0, −1. What is its matched filter h (for white noise)?
The matched filter is the pulse flipped in time: h[k] = p[L − 1 − k]. Reading 3, 1, 0, −1 backwards gives −1, 0, 1, 3. Any scaled copy works equally well, but a sign or order change does not.
02With white noise of RMS σ = 1 mV, what SNR does the matched filter give for the pulse 2, 2, 2, 2, 1, 1, 1, 1 mV?
SNR_max = E/σ², and E = Σ p² = 4 × 4 + 4 × 1 = 20 mV², so SNR = 20 / 1 = 20 (13.0 dB). A plain sum gets 18 and one sample only 4.
03Two pulses have the same energy but different shapes. Each gets its own matched filter. Which gives the higher SNR in the same white noise?
The best SNR is E/σ² (2E/N0 in continuous time). It depends only on the pulse energy, not on its shape, as long as the filter is matched to that shape.
04The matched filter's output peaks at time T = n0 + L − 1. For a pulse that starts at n0 = 8 with L = 8 samples, which output sample should the receiver read?
The output peaks when the sliding window covers the whole pulse, which is when its last sample n0 + L − 1 = 8 + 8 − 1 = 15 has arrived.
05With polar bits and a threshold of 0, an output SNR of 4 gives P(error) = Q(2) ≈ 2.3 %. What does an SNR of 20 give?
P(error) = Q(√SNR). √20 ≈ 4.47, and Q(4.47) ≈ 3.9e-6: about 3.9 errors in a million bits. Going from 6 dB to 13 dB of SNR cuts the error rate about 6000 times.
Glossary
- Matched filter
- The filter whose impulse response is the expected pulse flipped in time (and conjugated, for complex pulses). In white noise it gives the largest output SNR at one sampling instant.
- Signal-to-noise ratio (SNR)
- Signal power divided by noise power, here measured at the one output sample the receiver reads. In decibels: 10·log10(SNR).
- White noise
- Noise with the same power at every frequency (a flat power spectral density), so samples at different times are uncorrelated.
- Pulse energy E
- The sum of the squared pulse samples, Σ p[k]² (the integral of p(t)² in continuous time).
- Cauchy–Schwarz inequality
- (Σ a·b)² ≤ Σa²·Σb², with equality only when one list is a scaled copy of the other. It proves the matched filter is the best.
- Correlator
- A receiver that multiplies the input by the expected pulse and adds the products; read at the right time it gives the same value as the matched filter.
- Q-function
- Q(x) is the probability that a standard normal value exceeds x; polar bits decided at 0 are wrong with probability Q(√SNR).
Notes and sources
- The pulse p = 2, 2, 2, 2, 1, 1, 1, 1 mV and the noise RMS σ = 1 mV are chosen example values. The noise on the plots is one draw from a seeded random generator; the SNR values are exact averages over all draws, and every number in the figure is computed from this model.
- In continuous time the same result reads SNR_max = 2E/N0, where N0/2 is the two-sided power spectral density of the white noise and E the pulse energy. The discrete σ² plays the part of N0/2.
- Real links use smooth Nyquist pulses rather than blocks. Splitting a raised-cosine response into a root-raised-cosine filter at the transmitter and the same filter at the receiver makes the receiver a matched filter while keeping zero intersymbol interference.
- J. G. Proakis, Digital Communications, 3rd ed., McGraw-Hill, 1995 (optimum receivers for additive white Gaussian noise, the matched filter) (Internet Archive record)
- B. P. Lathi, Modern Digital and Analog Communication Systems, Holt, Rinehart and Winston, 1983 (optimum detection, the matched filter) (Internet Archive record)
- A. V. Oppenheim, A. S. Willsky, S. H. Nawab, Signals and Systems, 2nd ed., Pearson (convolution and correlation)
- MIT OpenCourseWare 6.011 Introduction to Communication, Control, and Signal Processing (A. V. Oppenheim, G. Verghese): detection, matched filters
- MIT OpenCourseWare 6.450 Principles of Digital Communications I (R. Gallager, L. Zheng): detection, the Nyquist criterion
- MIT OpenCourseWare 6.02 Introduction to EECS II: Digital Communication Systems (H. Balakrishnan, G. Verghese)
- Matched filter (Wikipedia): SNR of a linear filter, the Cauchy–Schwarz bound, the time-reversed template for white noise
- Cauchy–Schwarz inequality (Wikipedia)
- Additive white Gaussian noise (Wikipedia)
- Q-function (Wikipedia): Q(x) = ½·erfc(x/√2), table of values
- Root-raised-cosine filter (Wikipedia): matched filtering at transmitter and receiver, combined raised-cosine response
- NumPy documentation: numpy.convolve
- NumPy documentation: numpy.random.Generator.normal
Quiz Unlocks after the last step.