# A Machine Learning Based Algorithm as an Alternative to the Matched Filter

Consider we have to detect a known signal added with Gaussian noise. In this scenario, the matched filter is known to be an optimal filter for SNR. The question: is there any machine learning algorithm/tool that can be used instead of matched filter? Can we have any other detection technique instead of filter (convolution)?

• Interesting. Marking to answer this with a nice experiment :-).
– Royi
Commented Apr 22, 2022 at 20:50
• @Royi Thank you, I would love to see the result. Commented Apr 22, 2022 at 21:07
• @Royi I know we did quite a few of these at our institute, couple years back: students demonstrating a NN learning the optimal receive processing for a nonlinear channel converging against the matched filter as one reduces the channel nonlinearity, students demonstrating the matched filter can not only be learned with classical (R)NN architectures but also spiking neural networks … these kinds of things. Commented Apr 22, 2022 at 21:09
• @MarcusMüller, Could you share paper? Code? Interesting. Well, for the detection part the Matched Filter indeed optimal at any SNR. But we use Matched Filter for other objectives as well. While it is still great, we might beat it for some cases...
– Royi
Commented Apr 22, 2022 at 21:37
• @Royi OK, let's start with this, because it's a publication that was based on work my Prof had done with his prior employer: opg.optica.org/jlt/abstract.cfm?uri=jlt-36-20-4843 not actually about matched filters, but about "how do I get the best error rates / highest data rates in a nonlinear channel through machine learning". It's pretty cool how far the found solution generalizes, i.e. for what range of distances a net trained for a single distance (but some variation) still works! Commented Apr 22, 2022 at 21:48

The idea is to have a simple experiment to see if we can get, for a known signal, a better results than the Matched Filter for time delay estimation.

## Experiment Objective

Generate, using ML (DL), a system which estimates time delay under the model of a shifted signal with Additive Gaussian White Noise (AWGN).

## Experiment Motivation

It is known that the performance Matched Filter for time delay estimation is far from the CRLB at Low SNR scenario. It is not known if the CRLB is too optimistic (As it isn't guaranteed to be a tight lower bound) or the Matched Filter (MLE for this case) is not optimal for such case. This could be some kind of an empirical way to assess which one of the alternatives is more probable.

## Optimality of the Matched Filter

Pay attention that the Matched Filter is the global optimum for detection by being the operation, linear or non linear, which maximizes the SNR (Easy to prove with Cauchy Schwartz). Yet this optimality is in the context of detection (There is or no signal of interest). This experiment is about estimating the delay of the signal.

## Data

I created a simple Gaussian signal:

The signal is built with 201 samples.

Then I created 1,000,000 signals with shifted versions of the signal with various levels of added noise (The noise STD was in the range of [0, 1]).

For example, here is a shifted and noisy signal:

In he above, the signal was shifted by 3 samples. In order to make things easier I kept the shift to be an integer. It was done to prevent the need to create interpolation phase, etc...
The support of the shifted signal was 300 samples. Hence we had 100 different possible shifts (1 to 100).

I created 2 data sets: Train (1,000,000 signals) and Test (100,000 signals).

I created the simplest 1D CNN using Keras:

modelNet = keras.Sequential()
modelNet.add(keras.layers.Dense(units = 100, activation = 'softmax'))



The above is classification network, basically having to choose between 100 classes (Each per shift).

Trained it for 21 Epochs and got accuracy of 30.05% (Some checkpoint got even better):

Now, what would the Matched Filter do?

It gets 29.52%. So the 1D CNN got 0.5% more accuracy. Not bad for ~60 minutes work.

Let's have a look on the per signal performance of all:

In the above we see the best check point of the net training.

Zooming in to a specific delay (38):

The interesting thing is that the Matched Filter doesn't miss at high SNR (The left part). Since the overall of the 1D CNN is better it means it mainly beats it in lower SNR.

This validates my assertion, one could beat the Matched Filter for time delay estimation in the Low SNR zone and a great candidate to do so is using CNN.
By the way, even in the RMSE the Matched Filter was beaten by the 1D CNN (2.6954 vs 2.7771).

Few remarks:

• Pay attention that the 1D CNN didn't get any information about the signal itself (The reference). Result would be better if it did. One way to do it, the simplest, is to let it work on the cross correlation data. In my opinion well tweaked model working on the cross correlation can get over 35%.
• The experiment should be done for a regression model with fractional delay. Though it is valid for cases the quantization holds (For instance if the sampling frequency is high enough).
• @Royi because it's not an answer. Commented Apr 23, 2022 at 4:49
• But it is an answer in progress. I am not done.
– Royi
Commented Apr 23, 2022 at 5:05
• @Royi An answer in progress is not an answer. Commented Apr 23, 2022 at 14:30
• @DanBoschen "for any other noise conditions or non-linear, non-stationary channels it is well understood that the matched filter would no longer be the optimum solution" -- certainly, the conventional matched filter would not be optimum, but there could still be a filter, designed for those specific conditions, that is optimum (just like the MF is designed for AWGN). Optimum filtering is like channel capacity: you need to calculate it for your specific channel, and the usual formula only applies to a specific channel.
– MBaz
Commented Apr 23, 2022 at 15:49
• @MBaz Ah I am with you now, yes good point. It doesn't sound like that is related the OP's question however since he conditions it as for a known signal with an AWGN channel. But if we make the question different, we would get a different answer. So my comment here was for Royi's interesting experiment in case it would have a different conclusion from what Marcus already answered (which would then change the current understanding and be very interesting). If the experiment was for some other case, then it would just confuses the question at hand Commented Apr 23, 2022 at 16:08

Sure, you can learn the matched filter, as convolution with a filter is just a function applied to a signal, and e.g. Neural Networks (through the universal approximation theorem) are good function approximators.

But the fact that the matched filter is optimal in AWGN channels means exactly that: it's optimal, you can't do better than it. So there's really no point, other than showing you can learn it, in learning it. The classical, analytical methods work, and their provably the best.

Interesting problems arise when you e.g. want to minimize error in cases the channel is not AWGN, your reception is irregularly quantized etc., i.e., in cases where the analytical derivation of an optimal receive processing does not exist (or only exists in high complexity).

• Isn't the matched filter optimal only over the subset of linear filters, meaning that a non-linear filter could perform better than it in certain situations? Commented Apr 23, 2022 at 7:49
• @JacopoTissino ah, we do have to constrain ourselves to AWGN as channel (in other situations the matched filter itself is not necessarily optimal). And in the AWGN channel, decision based on sampling the matched filter is maximum likelihood, so a nonlinear filter can't be better :) Commented Apr 23, 2022 at 8:51
• Totally agree. Machine Learning is not a catch-all that would obsolete traditional signal processing. Machine Learning is best for solving the previously unsolvable problems. If used for problems that are already solved with other methods, machine learning will also solve it, but will much less efficiency. The Matched Filter under AWGN with stationary channel conditions is certainly not in that camp. However a matched for a non-linear and/or non-stationary channel (in such conditions that our traditional solutions are not yet optimum) may have promise with ML. Commented Apr 23, 2022 at 13:36
• Reminds me of a paper which has crossed my table where authors spent three pages learning the linear least squares approximation with neural nets. It was about 0.3% "worse" on the training set than your regular least squares and about 0.2% "better" on the test one. Still trying to wrap my head around why'd people do that... Commented Apr 23, 2022 at 19:23
• @Lodinn 1. it's a legitimate exercise to prove your learning architecture can learn! 2. Often, your end goal is not replicating a single element from a signal processing chain, but combine that with successive steps, either to build something that, through joint optimization does work better than the two separate things, or to then "prune" parts from your neural network, so that in the end the resulting NN algorithm is less complex than the classical method while still achieving approximately the same performance. Commented Apr 23, 2022 at 19:26