# Understanding the Matched Filter

I have a question about matched filtering. Does the matched filter maximise the SNR at the moment of decision only? As far as I understand, if you put, say, NRZ through a matched filter, the SNR will be maximised at the decision point only and that is the advantage of the matched filter. Does it maximise the SNR anywhere else in the output function, or just at the point of decision?

According to Wikipedia

The matched filter is the optimal linear filter for maximizing the signal to noise ratio (SNR) in the presence of additive stochastic noise

This to me implies that it maximises it everywhere, but I don't see how that is possible. I've looked at the maths in my communications engineering textbooks, and from what I can tell, it's just at the decision point.

Another question I have is, why not make a filter that makes a really tall skinny spike at the point of decision. Wouldn't that make the SNR even better?

Thanks.

Edit: I guess what I'm also thinking is, say you have a some NRZ data and you use a matched filter, the matched filter could be implemented with an I&D (integrate and dump). The I&D will basically ramp up until it gets to the sampling time and the idea is that one samples at the peak of the I&D because at that point, the SNR is a maximum. What I don't get is, why not create a filter that double integrates it or something like that, that way, you'd have a squared increase (rather than a ramp) and the point at which you sample would be even higher up and from what I can tell, more likely to be interpreted correctly by the decision circuit (and give a lower Pe (probability of error))?

• Read this answer and specifically the link in the last sentence. Your double integration is effectively computing the output (at the desired sampling time) of a non-matched filter and so cannot give a smaller $P_e$ than the matched filter if the noise is additive Gaussian. If the noise is additive Gaussian noise, then no filter, whether linear or nonlinear, can give a smaller error probability than the matched filter. – Dilip Sarwate May 12 '13 at 15:11

Since this question has multiple sub-questions in edits, comments on answers, etc., and these have not been addressed, here goes.

Matched filters

Consider a finite-energy signal $s(t)$ that is the input to a (linear time-invariant BIBO-stable) filter with impulse response $h(t)$, transfer function $H(f)$, and produces the output signal $$y(\tau) = \int_{-\infty}^\infty s(\tau-t)h(t)\,\mathrm dt.\tag{1}$$ What choice of $h(t)$ will produce a maximum response at a given time $t_0$? That is, we are looking for a filter such that the global maximum of $y(\tau)$ occurs at $t_0$. This really is a very loosely phrased (and really unanswerable) question because clearly the filter with impulse response $2h(t)$ will have larger response than the filter with impulse response $h(t)$, and so there is no such thing as the filter that maximizes the response. So, rather than compare apples and oranges, let us include the constraint that we seek the filter that maximizes $y(t_0)$ subject to the impulse response having a fixed energy, for example, subject to $$\int_{-\infty}^\infty |h(t)|^2\,\mathrm dt = \mathbb E = \int_{-\infty}^\infty |s(t)|^2 \,\mathrm dt.\tag{2}$$

Here onwards, "filter" shall mean a linear time-invariant filter whose impulse response satisfies (2).

The Cauchy-Schwarz inequality provides an answer to this question. We have $$y(t_0) = \int_{-\infty}^\infty s(t_0-t)h(t)\,\mathrm dt \leq \sqrt{\int_{-\infty}^\infty |s(t_0-t)|^2 \,\mathrm dt} \sqrt{\int_{-\infty}^\infty |h(t)|^2\,\mathrm dt} = \mathbb E$$ with equality occurring if $h(t) = \lambda s(t_0-t)$ with $\lambda > 0$ where from (2) we get that $\lambda = 1$, that is, the filter with impulse response $h(t) = s(t_0-t)$ produces the maximal response $y(t_0) = \mathbb E$ at the specified time $t_0$. In the (non-stochastic) sense described above, this filter is said to be

the filter matched to $s(t)$ at time $t_0$ or the matched filter for $s(t)$ at time $t_0.$

1. The output of the matched filter has a unique global maximum value of $\mathbb E$ at $t_0$; for any other $t$, we have $y(t) < y(t_0) = \mathbb E$.

2. The impulse response $s(t_0-t) = s(-(t-t_0))$ of the matched filter for time $t_0$ is just $s(t)$ "reversed in time" and moved to the right by $t_0$.

a. If $s(t)$ has finite support, say, $[0,T]$, then the matched filter is noncausal if $t_0 < T$.

b. The filter matched to $s(t)$ at time $t_1 > t_0$ is just the filter matched at time $t_0$ with an additional delay of $t_1-t_0$. For this reason, some people call the filter with impulse response $s(-t)$, (that is, the filter matched to $s(t)$ at $t=0$) the matched filter for $s(t)$ with the understanding that the exact time of match can be incorporated into the discussion as and when needed. If $s(t) = 0$ for $t < 0$, then the matched filter is noncausal. With this, we can rephrase 1. as

3. The matched filter for $s(t)$ produces a unique global maximum value $y(0) = \mathbb E$ at time $t=0$. Furthermore, $$y(t) = \int_{-\infty}^\infty s(t-\tau)s(-\tau)\,\mathrm d\tau = \int_{-\infty}^\infty s(\tau-t)s(\tau)\,\mathrm d\tau = R_s(t)$$ is the autocorrelation function of the signal $s(t)$. It is well-known, of course, that $R_s(t)$ is an even function of $t$ with a unique peak at the origin. Note that the output of the filter matched at time $t_0$ is just $R_s(t-t_0)$, the autocorrelation function delayed to peak at time $t_0$.

4. No filter other than the matched filter for time $t_0$ can produce an output as large as $\mathbb E$ at $t_0$. However, for any $t_0$, it is possible to find filters that have outputs that exceed $R_s(t_0)$ at $t_0$. Note that $R_s(t_0) < \mathbb E$.

5. The transfer function of the matched filter is $H(f)=S^*(f)$, the complex conjugate of the spectrum of $S(f)$. Thus, $Y(f) = \mathfrak F[y(t)]= |S(f)|^2$. Think of this result as follows. Since $x^2 > x$ for $x > 1$ and $x^2< x$ for $0 < x < 1$, the matched filter has low gain at those frequencies where $S(f)$ is small, and high gain at those frequencies where $S(f)$ is large. Thus, the matched filter is reducing the weak spectral components and enhancing the strong spectral components in $S(f)$. (It is also doing phase compensation to adjust all the "sinusoids" so that they all peak at $t=0$).

## -------

But what about noise and SNR and stuff like that which is what the OP was asking about?

If the signal $s(t)$ plus additive white Gaussian noise with two-sided power spectral density $\frac{N_0}{2}$ is processed through a filter with impulse response $h(t)$, then the output noise process is a zero-mean stationary Gaussian process with autocorrelation function $\frac{N_0}{2}R_s(t)$. Thus, the variance is $$\sigma^2 = \frac{N_0}{2} R_s(0) = \frac{N_0}{2}\int_{-\infty}^{\infty} |h(t)|^2\,\mathrm dt.$$ It is important to note that the variance is the same regardless of when we sample the filter output. So, what choice of $h(t)$ will maximize the SNR $y(t_0)/\sigma$ at time $t_0$? Well, from the Cauchy-Schwarz inequality, we have $$\text{SNR} = \frac{y(t_0)}{\sigma} = \frac{\int_{-\infty}^\infty s(t_0-t)h(t)\,\mathrm dt}{\sqrt{\frac{N_0}{2}\int_{-\infty}^\infty |h(t)|^2\,\mathrm dt}} \leq \frac{\sqrt{\int_{-\infty}^\infty |s(t_0-t)|^2 \,\mathrm dt} \sqrt{\int_{-\infty}^\infty |h(t)|^2\,\mathrm dt}}{\sqrt{\frac{N_0}{2}\int_{-\infty}^\infty |h(t)|^2\,\mathrm dt}} = \sqrt{\frac{2\mathbb E}{N_0}}$$ with equality exactly when $h(t) = s(t_0-t)$, the filter that is matched to $s(t)$ at time $t_0$!! Note that $\sigma^2 = \mathbb EN_0/2$. If we use this matched filter for our desired sample time, then at other times $t_1$, the SNR will be $y(t_1)/\sigma < y(t_0)/\sigma = \sqrt{\frac{2\mathbb E}{N_0}}$. Could another filter give a larger SNR at time $t_1$? Sure, because $\sigma$ is the same for all filters under consideration, and we have noted above that it is possible to have a signal output larger than $y(t_1)$ at time $t_1$ by use of a different non-matched filter.

In short,

• "does the matched filter maximize the SNR only at the sampling instant, or everywhere?" has the answer that the SNR is maximized only at the sampling instant $t_0$. At other times, other filters could give a larger SNR than what the matched filter is providing at time $t_1$, but this still smaller than the SNR $\sqrt{\frac{2\mathbb E}{N_0}}$ that the matched filter is giving you at $t_0$, and if desired, the matched filter could be redesigned to produce its peak at time $t_1$ instead of $t_0$.

• "why not make a filter that makes a really tall skinny spike at the point of decision. Wouldn't that make the SNR even better?"
The matched filter does produce a spike of sorts at the sampling time but it is constrained by the shape of the autocorrelation function. Any other filter that you can devise to produce a tall skinny (time-domain) spike is not a matched filter and so will not give you the largest possible SNR. Note that increasing the amplitude of the filter impulse response (or using a time-varying filter that boosts the gain at the time of sampling) does not change the SNR since both the signal and the noise standard deviation increase proportionately.

• "The I&D will basically ramp up until it gets to the sampling time and the idea is that one samples at the peak of the I&D because at that point, the SNR is a maximum."
For NRZ data and rectangular pulses, the matched filter impulse response is also a rectangular pulse. The integrate-and-dump circuit is a correlator whose output equals the matched filter output only at the sampling instants, and not in-between. See the figure below.

If you sample the correlator output at other times, you get noise with smaller variance but you can't simply add up the samples of I&D output taken at different times because the noise variables are highly correlated, and the net variance works out to be much larger. Nor should you expect to be able to take multiple samples from the matched filter output and combine them in any way to get a better SNR. It doesn't work. What you have in effect is a different filter, and you cannot do better than the (linear) matched filter in Gaussian noise; no nonlinear processing will give a smaller error probability than the matched fiter.

• Great answer. There's a significant portion of a digital communication theory course shoved into one package. – Jason R Jun 2 '13 at 12:39
• Thank you for the great answer! I have a question regarding the graph of the matched filter output. What's the output of that graph (I'm trying to hand draw it)? I'm assuming that it's $y(t) = r(t) * r(-t)$ where $y(t)$ is the output signal (third graph) and $r(t)$ is the received signal (first graph). If I correlate the received signal with a box function tall enough to pass encompass both the logic level 1 and 0 states, then I get that output---the only thing is, there is never a 100% match between the correlated signal and the correlation signal, perhaps that is to be expected. – user968243 Jun 7 '13 at 6:46
• With $p(t)$ denoting a rectangular pulse lasting from $0$ to $T$, the received signal is $r(t)=\sum_{n=0}^\infty (-1)^{b_n}p(t-nT)$, the matched filter has impulse response $h(t)=p(-t)$ and the filter output is $$(r\star h)(t)=\int_{-\infty}^\infty r(u)h(t-u)\,du=\int_{-\infty}^\infty r(u)p(u-t)\,du=\int_{t-T}^t r(u)\,du,$$ that is, the matched filter output at any time $t$ is the integral of the received signal (plus noise, of course) over the past $T$ seconds. Note that except at the sampling instants, the filter output has receiver-induced intersymbol interference (ISI) in it! (continued) – Dilip Sarwate Jun 7 '13 at 10:57
• (continued) This ISI is another reason why your idea of taking multiple samples from the matched filter output and then processing them somehow to improve SNR will not work as well as you think it might. – Dilip Sarwate Jun 7 '13 at 10:59
• Okay thanks! It seems to me, though, that the matched filter really is a correlator... It's just that the correlator in graph two is really implemented as an integrator that needs to restart integrating every T in order to look like a correlator at T. Seems to me that the matched filter is more like a correlator than the correlator (I know that sounds odd). – user968243 Jun 7 '13 at 12:11

You are right: A matched filter will maximize SNR at the instant of decision.

Note that your proposal of a tall spike "filter" is not a filter, but actually a sampler (the sampler used at the decision point).

The matched filter is a filter (i.e. linear time-invariant system) applied to the continuous input signal. The "spike at the point of decision" is very time-dependant (it is not a filter but a sampler).

• I've added an edit to my question. I tried to post it in the comments here but it was too long and not allowed. Thanks for your answer. – user968243 May 12 '13 at 4:39

The matched filter is the maximum-likelihood receiver in the presence of additive white Gaussian noise. Thus, for equal prior symbol probabilities, it will yield optimum bit-error performance. This is equivalent on the AWGN channel to maximizing the signal-to-noise ratio, as you pointed out. You also correctly pointed out that this maximum-SNR condition is at the decision instant for each symbol.

The misconception in your proposal is that you can't do any better than the matched-filter approach on the AWGN channel. The output of the filter for time instants other than the decision point is irrelevant for bit-error performance. In a practical sense, it can be easier to obtain symbol-timing synchronization if the matched-filter output (i.e. the shape of the autocorrelation of the signal's pulse shape) has an impulse-like shape. In fact, some real communication techniques (like direct sequence spread spectrum modulation) have this property.

Assuming perfect synchronization, however, which is the typical case when analyzing bit-error rates, the performance that is attained is unrelated to the shape of the matched filter's output; all that matters is the total energy in the pulse, which determines the value of the matched filter's output at the decision point.

Furthermore, it can be very difficult to design a different filter that would have the specific time-domain response that you want. Such a process is known as deconvolution, and isn't easy. The double-filter approach that you suggest would actually have the opposite effect of smearing out the decision statistic even further (convolution inherently smears the signal out in time). You could perhaps devise some nonlinear filter that would give you a shape that you like more, but it isn't clear that it would retain the optimality of the matched filter approach.

• Okay, thanks for the reply. You said that the output of the matched filter not at the decision point make no difference and are irrelevant. I had figured this out and was wondering why a better filter could not be made, say, one that grabs the energy contained in those portions and includes that at the point of decision. Not sure if that makes sense! Hope it does! My guess is that this can't be done because then the filter wouldn't be linear... – user968243 May 12 '13 at 16:50

I cannot answer your question in theory, however I can answer it practically - You may see it using a matched filter simulator (http://www.grauonline.de/alexwww/ardumower/filter/filter.html).

All the above answers nicely describe how matched filter is optimal but do not discuss why other samples are useless as far as decision is concerned. The interesting perspective on these non-optimal samples comes from taking a frequency domain view.

Remember that cross-correlation in time domain is conjugate multiplication in frequency domain. When sampled at the optimal instant, the phases of all frequency bins are aligned such that the energy is maximized in I branch of the result and there is no Q arm. When sampled at another instant, phase rotations are introduced due to this time shift difference which are different for each frequency bin. See the figure below.

Moreover, the noise samples, having passed through the matched filter, become correlated. This correlation is zero only when matched filter output crosses zeros, i.e., optimal sampling instants.

It is explained in much more detail in the article on demodulation.

Sometimes it is more useful to have a filter with a small tiny spike in the middle like you said. One such filter is called the MACE filter. This is the original paper

Mahalanobis, A., Kumar, B.V.K.V., Casasent, D.: Minimum average correlation energy ﬁlters. Appl. Opt. 26, 3630–3633 (1987)