Forums

Correlation Versus Simple Filter

Started by Randy Yates July 31, 2019
Gentle Readers,

Ok, I've been out of DSP for way too long so maybe this is
a stupid question, but in the interest of getting my feet
wet again, here goes.

Let's say we have a tone which we want to detect. Which is going to give
better performance, correlation followed by a threshold or a simple
bandpass filter followed by an energy detector and threshold?
-- 
Randy Yates, DSP/Embedded Firmware Developer
Digital Signal Labs
http://www.digitalsignallabs.com
On 1.8.19 05:06, Randy Yates wrote:
> Gentle Readers, > > Ok, I've been out of DSP for way too long so maybe this is > a stupid question, but in the interest of getting my feet > wet again, here goes. > > Let's say we have a tone which we want to detect. Which is going to give > better performance, correlation followed by a threshold or a simple > bandpass filter followed by an energy detector and threshold? >
You're probably looking for the Goertzel algorithm for single tone detection. Correlation is a kind of filter. The longer correlation the narrower filter. -- -TV
Tauno Voipio  <tauno.voipio@notused.fi.invalid> wrote:

>On 1.8.19 05:06, Randy Yates wrote:
>> Ok, I've been out of DSP for way too long so maybe this is >> a stupid question, but in the interest of getting my feet >> wet again, here goes.
>> Let's say we have a tone which we want to detect. Which is going to give >> better performance, correlation followed by a threshold or a simple >> bandpass filter followed by an energy detector and threshold?
>You're probably looking for the Goertzel algorithm for single >tone detection.
>Correlation is a kind of filter. The longer correlation the >narrower filter.
If the signal being detected is a tone, as Tauno said these methods are similar and both work. If the signal being detected is a time-domain signal more complicated than a tone, then a correlator would be useful. Steve
On Wednesday, July 31, 2019 at 9:06:13 PM UTC-5, Randy Yates wrote:
> Gentle Readers, > > Ok, I've been out of DSP for way too long so maybe this is > a stupid question, but in the interest of getting my feet > wet again, here goes. > > Let's say we have a tone which we want to detect. Which is going to give > better performance, correlation followed by a threshold or a simple > bandpass filter followed by an energy detector and threshold? > -- > Randy Yates, DSP/Embedded Firmware Developer > Digital Signal Labs > http://www.digitalsignallabs.com
A correlator (IF you can get it to work right) is effectively a COHERENT matched filter/detector for the tone and will give a more reliable detection of the tone than the band-ass fllter followed by the energy detector and threshold which is a NONCOHERENT detector (though the difference is small at high SNR). The difficulty with coherent detection is, of course, getting the synchronization of the local oscillator and the incoming tone just right. So, if cost of the implementation lor weight or power consumption) is at all a concern, go with the incoherent approach (especially at high SNR). Dilip Sarwate
dvsarwate <dvsarwate@yahoo.com> writes:

> On Wednesday, July 31, 2019 at 9:06:13 PM UTC-5, Randy Yates wrote: >> Gentle Readers, >> >> Ok, I've been out of DSP for way too long so maybe this is >> a stupid question, but in the interest of getting my feet >> wet again, here goes. >> >> Let's say we have a tone which we want to detect. Which is going to give >> better performance, correlation followed by a threshold or a simple >> bandpass filter followed by an energy detector and threshold? >> -- >> Randy Yates, DSP/Embedded Firmware Developer >> Digital Signal Labs >> http://www.digitalsignallabs.com > > A correlator (IF you can get it to work right) is effectively a > COHERENT matched filter/detector for the tone and will give a more > reliable detection of the tone than the band-ass fllter followed by > the energy detector and threshold which is a NONCOHERENT detector > (though the difference is small at high SNR). The difficulty with > coherent detection is, of course, getting the synchronization of the > local oscillator and the incoming tone just right. So, if cost of the > implementation lor weight or power consumption) is at all a concern, > go with the incoherent approach (especially at high SNR).
Hi Dilip, It is very good to hear from you once again! Thanks to you, Tauno, and Steve (so far) for entertaining my question. This was a pure theory question, so I had no practical concerns in mind. Regarding "synchroniziation," did you mean of the tone's frequency, its phase, or both? So let's say you know the frequency precisely. You could estimate the tone's phase by correlating with cos(omega*t) and sin(omega*t) to find the phase viz f(t) = A*cos(omega*t) + B*sin(omega*t), then go back and correlate with the estimated phase. Right? If the tone isn't there, then your phase estimate would be garbage and the correlation would almost certainly not meet threshold. You could even get a little fancier (isn't it?) and construct the estimated tone, do a mean-squared error between it and the actual tone, threshold, and declare the phase estimate good or bad. Although it seems this is getting a little circular... However I did in fact use a very similar algorithm algorithm that seemed to work well for us at Ericsson to determine if the input signal to our frequency estimator, which itself was to estimate the slope C in the model f(t) = A*cos(omega*t) + B*sin(omega*t) + C*t + D. Our frequency locked loop was getting knocked off frequency at low SNRs due to a noisy input signal, so with the algorithm above we simply skipped the loop update if the signal was deemed too noisy (i.e, if the mean-square error between the model estimates signal and the actual signal was too high). Very cool stuff! Thanks for the discussion! -- Randy Yates, DSP/Embedded Firmware Developer Digital Signal Labs http://www.digitalsignallabs.com
PS: Thanks for reminding me that this was an example of
coherent vs. non-coherent detection.

--Randy

Randy Yates <yates@digitalsignallabs.com> writes:

> dvsarwate <dvsarwate@yahoo.com> writes: > >> On Wednesday, July 31, 2019 at 9:06:13 PM UTC-5, Randy Yates wrote: >>> Gentle Readers, >>> >>> Ok, I've been out of DSP for way too long so maybe this is >>> a stupid question, but in the interest of getting my feet >>> wet again, here goes. >>> >>> Let's say we have a tone which we want to detect. Which is going to give >>> better performance, correlation followed by a threshold or a simple >>> bandpass filter followed by an energy detector and threshold? >>> -- >>> Randy Yates, DSP/Embedded Firmware Developer >>> Digital Signal Labs >>> http://www.digitalsignallabs.com >> >> A correlator (IF you can get it to work right) is effectively a >> COHERENT matched filter/detector for the tone and will give a more >> reliable detection of the tone than the band-ass fllter followed by >> the energy detector and threshold which is a NONCOHERENT detector >> (though the difference is small at high SNR). The difficulty with >> coherent detection is, of course, getting the synchronization of the >> local oscillator and the incoming tone just right. So, if cost of the >> implementation lor weight or power consumption) is at all a concern, >> go with the incoherent approach (especially at high SNR). > > Hi Dilip, > > It is very good to hear from you once again! Thanks to you, Tauno, and > Steve (so far) for entertaining my question. > > This was a pure theory question, so I had no practical concerns in mind. > > Regarding "synchroniziation," did you mean of the tone's frequency, its > phase, or both? > > So let's say you know the frequency precisely. You could estimate the > tone's phase by correlating with cos(omega*t) and sin(omega*t) to find > the phase viz f(t) = A*cos(omega*t) + B*sin(omega*t), then go back and > correlate with the estimated phase. Right? > > If the tone isn't there, then your phase estimate would be garbage and > the correlation would almost certainly not meet threshold. > > You could even get a little fancier (isn't it?) and construct the > estimated tone, do a mean-squared error between it and the actual tone, > threshold, and declare the phase estimate good or bad. Although it seems > this is getting a little circular... > > However I did in fact use a very similar algorithm algorithm that seemed > to work well for us at Ericsson to determine if the input signal to our > frequency estimator, which itself was to estimate the slope C in the > model f(t) = A*cos(omega*t) + B*sin(omega*t) + C*t + D. Our frequency > locked loop was getting knocked off frequency at low SNRs due to a noisy > input signal, so with the algorithm above we simply skipped the loop > update if the signal was deemed too noisy (i.e, if the mean-square error > between the model estimates signal and the actual signal was too high). > > Very cool stuff! Thanks for the discussion!
-- Randy Yates, DSP/Embedded Firmware Developer Digital Signal Labs http://www.digitalsignallabs.com
On 2.8.19 09:54, Randy Yates wrote:
> dvsarwate <dvsarwate@yahoo.com> writes: > >> On Wednesday, July 31, 2019 at 9:06:13 PM UTC-5, Randy Yates wrote: >>> Gentle Readers, >>> >>> Ok, I've been out of DSP for way too long so maybe this is >>> a stupid question, but in the interest of getting my feet >>> wet again, here goes. >>> >>> Let's say we have a tone which we want to detect. Which is going to give >>> better performance, correlation followed by a threshold or a simple >>> bandpass filter followed by an energy detector and threshold? >>> -- >>> Randy Yates, DSP/Embedded Firmware Developer >>> Digital Signal Labs >>> http://www.digitalsignallabs.com >> >> A correlator (IF you can get it to work right) is effectively a >> COHERENT matched filter/detector for the tone and will give a more >> reliable detection of the tone than the band-ass fllter followed by >> the energy detector and threshold which is a NONCOHERENT detector >> (though the difference is small at high SNR). The difficulty with >> coherent detection is, of course, getting the synchronization of the >> local oscillator and the incoming tone just right. So, if cost of the >> implementation lor weight or power consumption) is at all a concern, >> go with the incoherent approach (especially at high SNR). > > Hi Dilip, > > It is very good to hear from you once again! Thanks to you, Tauno, and > Steve (so far) for entertaining my question. > > This was a pure theory question, so I had no practical concerns in mind. > > Regarding "synchroniziation," did you mean of the tone's frequency, its > phase, or both?
Both. You'll end up with a lock-in amplifier, google for it. You can work around on the phase requirement by making two copies at 90 degree phase difference and combine the results. -- -TV
> So let's say you know the frequency precisely. You could estimate the > tone's phase by correlating with cos(omega*t) and sin(omega*t) to find > the phase viz f(t) = A*cos(omega*t) + B*sin(omega*t), then go back and > correlate with the estimated phase. Right? >
Right, and another way to think of this approach is that you're correlating with e^(j*w*t). This gives you the coefficient of e^(j*w*t) in your signal. Since the signal is real, the coefficient of e^(-j*w*t) is then given by the complex conjugate. -Ethan
dvsarwate  <dvsarwate@yahoo.com> wrote:

>A correlator (IF you can get it to work right) is effectively a COHERENT >matched filter/detector for the tone and will give a more reliable >detection of the tone than the band-ass fllter followed by the energy >detector and threshold which is a NONCOHERENT detector (though the >difference is small at high SNR).
I love the phrase "band-ass filter". Somewhere between bandpass, bad-ass, and band-aid. It seems to be if you correlate with a quadrature signal, you can then process so as to do a non coherenent detector if you like. Further .. S.
Randy Yates wrote:
> Gentle Readers, > > Ok, I've been out of DSP for way too long so maybe this is > a stupid question, but in the interest of getting my feet > wet again, here goes. > > Let's say we have a tone which we want to detect. Which is going to give > better performance, correlation followed by a threshold or a simple > bandpass filter followed by an energy detector and threshold? >
I put a multiple-frequency ( but one at a time ) "guitar tuner"[1] together a few years back and autocorrelation of the extremely simplistic variety gave milliseconds response time at 44.1 sampling rate with very few false positives. This with 89 samples minimum time resolution ( the driver is configured for 2msec ) . I downloaded code from some guy at MIT for the actual pitch detector. URL available upon request - I'll have to dig a bit. I was also able to record the signal and the algorithm compared very favorably to what I could find with FFT. The bottleneck is,and will always be that a 20Hz signal takes 50msec to have a full cycle. So a lowest supported frequency above 20Hz is desired. So constraining your tone is in order. [1] don't ask. Just. Don't. Ask. -- Les Cargill