---
title: The matched filter
heading: Detecting a known pulse in white noise, the filter that maximizes the output SNR, its value 2E/N0, the correlator, and what a simple RC filter gives up
eyebrow: S8 · Lesson 13 · The matched filter
xp: 50
---

::: hook
A digital receiver has one job at each symbol instant: decide which of a few known pulses was sent, despite the noise riding on it. Before deciding, it should filter, and there's a best possible filter: the one that makes the pulse stand highest above the noise at the sampling instant. It turns out to be the pulse itself, reversed in time, and the signal-to-noise ratio it achieves depends only on the pulse's energy, not its shape. Every modem, radar and GPS receiver is built around this matched filter or its equivalent, the correlator.
:::

::: play
- The output SNR of a simple RC lowpass filter, sampled at the end of a rectangular pulse of duration T, relative to the matched filter's 2E/N0, against the filter's time constant τ (in units of T).
- Too short a τ lets in too much noise; too long a τ never lets the pulse build up. The best choice, τ ≈ 0.80T, still loses 0.89 dB.
- The matched filter for a rectangular pulse is an integrator over one symbol, integrate-and-dump, which reaches 0 dB on this scale exactly.
:::
:::

```sim plot
view: graph
x: t = 0.05..10 log
y: L = -12..0.5 dB
plot: 10*log(2*t*(1 - exp(-1/t))^2) | samples: 600 | label: RC filter SNR relative to matched, dB
plot: 0 | dashed | color: ch3 | label: matched filter
```

::: predict
## Two pulses have the same energy, one a short tall rectangle and the other a long chirp. Which gives the higher SNR after its own matched filter in white noise?

- [ ] The short pulse
- [ ] The chirp
- [x] They're equal: both give 2E/N0
- [ ] It depends on the noise bandwidth

::: reveal
Equal. The matched filter's peak output SNR is $2E/N_0$ for any pulse shape: only the energy matters. That's why radar can send a long, low-power chirp with the same detection performance as a short high-power pulse of equal energy, then compress it in the matched filter for fine range resolution.
:::
:::

::: nameit
## The matched filter

For a known pulse s(t), 0 ≤ t ≤ T, in white noise of two-sided density $N_0/2$, the filter maximizing the output SNR at t = T is

$$h(t) = s(T - t), \qquad \text{SNR}_\text{max} = \frac{2E}{N_0}, \quad E = \int_0^Ts^2(t)\,dt$$

(by the Cauchy–Schwarz inequality). Its output at t = T is E, plus noise of variance $N_0E/2$. In frequency, $H(f) = S^*(f)e^{-j2\pi fT}$: it passes each frequency in proportion to how much of the pulse is there and lines up all the phases to peak at T.

## The correlator

Sampling the matched filter at T is the same as computing $\int_0^Tr(t)s(t)\,dt$: multiply the received signal by a copy of the pulse and integrate. For a rectangular pulse this is **integrate-and-dump**.

## Practical filters

A filter that isn't matched loses SNR. For a rectangular pulse and an RC lowpass of time constant τ, sampled at T, the ratio to the matched filter is

$$\frac{\text{SNR}_\text{RC}}{\text{SNR}_\text{MF}} = \frac{2\tau}{T}\left(1 - e^{-T/\tau}\right)^2$$

at best 0.815 (−0.89 dB) with τ = 0.796T.
:::

::: example
## A rectangular pulse of 2 V lasting 10 µs arrives in noise with $N_0$ = 10⁻⁹ W/Hz (across 1 Ω). What SNR does a matched filter give, and what does an RC filter with τ = T give?

::: solution
1. **Pulse energy.** In V²·s across 1 Ω:
   $$\begin{aligned} E &= 2^2 \times 10\ \text{µs} \\ &= 40\ \text{µJ} \end{aligned}$$
2. **Matched filter.**
   $$\begin{aligned} \frac{2E}{N_0} &= \frac{2 \times 40 \times 10^{-6}}{10^{-9}} \\ &= 80\,000 \\ &= 49.0\ \text{dB} \end{aligned}$$
3. **RC filter with τ = T.** It gets a fraction of that:
   $$\begin{aligned} 2(1 - e^{-1})^2 &= 0.799 \\ &= -0.97\ \text{dB} \end{aligned}$$
   so 48.1 dB.
4. **RC filter with τ = 0.1T.** It would lose 7.0 dB.

**Answer:** the matched filter gives 49.0 dB and the RC filter with τ = T gives 48.1 dB.
:::
:::

::: example
## What's the matched filter for $s(t) = \sin(2\pi t/T)$ on 0 ≤ t ≤ T, and what's its peak output?

::: solution
1. **Reverse the pulse.**
   $$\begin{aligned} h(t) &= s(T - t) \\ &= \sin(2\pi(T - t)/T) \\ &= -\sin(2\pi t/T) \end{aligned}$$
   That's the pulse reversed, which for this odd-symmetric pulse is its negative.
2. **Peak output.** The output at T is the energy:
   $$\int_0^T\sin^2(2\pi t/T)\,dt = \frac{T}{2}$$

**Answer:** $h(t) = -\sin(2\pi t/T)$ on 0 ≤ t ≤ T, and its peak output, at t = T, is T/2.
:::
:::

::: example
## A half-sine pulse is received by an integrate-and-dump (rectangular template) instead of its matched filter. How much SNR is lost?

::: solution
1. **Efficiency of a template.** For a template w against a pulse s it's
   $$\frac{(\int sw)^2}{\int s^2\int w^2}$$
2. **Half-sine against a rectangle.** For $s = \sin(\pi t/T)$ and w = 1 on [0, T]:
   $$\begin{aligned} \frac{(2T/\pi)^2}{(T/2)T} &= \frac{8}{\pi^2} \\ &= 0.811 \end{aligned}$$
3. **In decibels.** That's a loss of 0.91 dB, almost exactly the best RC filter's 0.89 dB.
4. **Why match.** A correlator with the right shape costs nothing extra in hardware, which is why it's worth matching.

**Answer:** the integrate-and-dump loses 0.91 dB (an efficiency of 0.811).
:::
:::

::: check
given: E = 5 | 10 | 15
answer: E + 3.0103
unit: dB
tolerance: 0.05

## A pulse has E/N₀ = {E} dB. What's the matched filter's output SNR?

::: right
Right. $2E/N_0$: {answer} dB.
:::

::: misses
- [E] The peak SNR is twice E/N₀ with two-sided noise density $N_0/2$.
- [any] Not yet. $\text{SNR}_\text{max} = 2E/N_0$.
:::
:::

::: check
given: A = 0.5 | 2 | 5; T = 1 | 10 | 100
answer: A^2*T
unit: µJ
tolerance: 0.5%

## A rectangular pulse of {A} V lasts {T} µs (across 1 Ω). What's its energy?

::: right
Right. $A^2T$ = {answer} µJ.
:::

::: misses
- [A*T] Energy goes as the square of the amplitude.
- [any] Not yet. $E = \int s^2\,dt$.
:::
:::

::: check
given: r = 0.2 | 0.5 | 1 | 3
answer: 10*log(2*r*(1 - exp(-1/r))^2)
unit: dB
tolerance: 0.05

## An RC filter with τ = {r}T is used in place of a matched filter for a rectangular pulse. How much SNR does it lose?

::: right
Right. $\frac{2\tau}{T}(1 - e^{-T/\tau})^2$: {answer} dB.
:::

::: misses
- [any] Not yet. Peak $A(1 - e^{-T/\tau})$ against noise variance $N_0/4\tau$.
:::
:::

::: check
given: T = 1 | 8 | 50
answer: 0.796*T
unit: µs
tolerance: 0.5%

## What RC time constant gives the best SNR for a {T} µs rectangular pulse?

::: right
Right. τ ≈ 0.796T = {answer} µs, losing 0.89 dB.
:::

::: misses
- [T] Close, but the optimum is a little shorter than T.
- [any] Not yet. Maximize $\frac{2\tau}{T}(1 - e^{-T/\tau})^2$.
:::
:::

::: check
given: E = 1 | 4 | 25; N = 0.01 | 0.1
answer: sqrt(N*E/2)
tolerance: 0.5%

## A correlator's signal output is E = {E} (in its units). With noise density $N_0$ = {N}, what's the rms noise at its output?

::: right
Right. $\sqrt{N_0E/2}$ = {answer}.
:::

::: misses
- [sqrt(N*E)] The two-sided density is $N_0/2$.
- [N*E/2] That's the variance; take the square root.
- [any] Not yet. Variance $N_0E/2$.
:::
:::

::: check
given: A = 1 | 3; T = 2 | 5; t = 0.25 | 0.5 | 0.75
answer: A^2*T*t
tolerance: 0.5%

## A rectangular pulse of amplitude {A} and duration {T} passes through its matched filter (integrate-and-dump, unit gain). What's the output a fraction {t} of the way through the pulse?

::: right
Right. The integral so far: $A^2Tt$ = {answer}, peaking at $A^2T$ at the end.
:::

::: misses
- [A^2*T] That's the peak, reached only at the end of the pulse.
- [any] Not yet. The output ramps linearly up to E.
:::
:::

::: check
kind: parts
given: A = 0.5 | 2; T = 1 | 10; N = 1e-9 | 1e-8; r = 0.4 | 0.796 | 2

## A rectangular pulse of {A} V lasting {T} µs arrives (across 1 Ω) with $N_0$ = {N} W/Hz.

::: part
answer: 10*log(2*A^2*T*1e-6/N)
unit: dB
tolerance: 0.5%

### What SNR does its matched filter give?

::: misses
- [10*log(A^2*T*1e-6/N)] The matched filter gives 2E/N₀.
- [any] $2E/N_0$ with $E = A^2T$.
:::
:::

::: part
answer: 10*log(2*A^2*T*1e-6/N) + 10*log(2*r*(1 - exp(-1/r))^2)
unit: dB
tolerance: 0.5%

### What does an RC filter with τ = {r}T give?

::: misses
- [any] Multiply by $\frac{2\tau}{T}(1 - e^{-T/\tau})^2$.
:::
:::
:::

::: check
kind: derivation
vars: A = 0.1..10, T = 1e-7..1e-3, N = 1e-12..1e-6

## A rectangular pulse of amplitude A and duration T arrives with noise density N (one-sided), across 1 Ω.

::: step
answer: A^2*T

### What is its energy?
:::

::: step
answer: 2*A^2*T/N

### What SNR does the matched filter give?
:::

::: step
answer: N*A^2*T/2

### What is the noise variance at the sampled output?
:::

::: right
Right. The signal output is E and the noise variance $N_0E/2$, so the ratio of signal squared to noise is $2E/N_0$.
:::
:::

::: explain
## Why does the matched filter's best SNR depend only on the pulse's energy, not its shape?

::: model
White noise has the same power in every frequency and is uncorrelated from instant to instant, so it has no preferred shape. The matched filter adds up the received signal weighted by the pulse itself, so each part of the pulse contributes in proportion to its own strength, and the total signal at the output is the pulse's energy. The noise passing through the same weights adds up incoherently, giving a variance that also grows with the energy, but only its square root. The ratio of the signal squared to the noise variance is therefore proportional to the energy alone. How that energy is spread in time or frequency changes what the output looks like, not how far it stands above the noise.
:::
:::

::: practice

::: check
given: E = 2 | 3 | 6 | 8 | 10 | 12
answer: E + 3.0103
unit: dB
tolerance: 0.05

## MF output SNR for E/N₀ = {E} dB?

::: misses
- [any] $2E/N_0$.
:::
:::

::: check
given: r = 0.2 | 0.4 | 0.5 | 0.8 | 1 | 2
answer: 10*log(2*r*(1 - exp(-1/r))^2)
unit: dB
tolerance: 0.05

## RC filter loss at τ = {r}T?

::: misses
- [any] $\frac{2\tau}{T}(1 - e^{-T/\tau})^2$.
:::
:::

::: check
given: A = 1.5 | 4; T = 3 | 20
answer: A^2*T
unit: µJ
tolerance: 0.5%

## Energy of a {A} V, {T} µs pulse?

::: misses
- [any] $A^2T$.
:::
:::
:::
