# Looking for an algorithm that computes "Similarity" between two signals

I'm new in this forum! ... and I'm not an expert in signal processing! ... So I hope to find help here:-)
I was wondering if someone could point me to an algorithm/technique that is used to compare time dependent signals. Ideally, this hypothetical algorithm would take in 2 signals as inputs and return a number that would be the percentage similarity between the signals. In other terms I’m looking for a technique that allows to establish a degree of “similarity” between the two signals even if there is a delay or a shift between them. Obviously, if this technique could be implemented in a recursive way or with a small number of point ...it would be great! :-)

Thanks

Coherence? As in: http://en.wikipedia.org/wiki/Coherence_(signal_processing). By comparing the signal spectrums, you get real number numbers between 0 and 1, which each number is a measure of the similarity of the two signals at each frequency. But it might be difficult for a beginner to understand and program. You might look for simpler explanations and/or examples by doing a Google search for 'signal coherence', which results in about 17 million hits.

I would recommend something like cross-correlation. This technique has a strong theoretical foundation and works well at compensating for things like time delay.

It might be easier to answer your questions if you provide a more thorough explanation as to what kinds of signal properties you are looking to compare between the two signals.

As a fellow person who might have difficulty implementing that, shooting from the hip I might try taking the fft of the two signals, treating that as a complex value vector of N dimensions where N is the number off fft bins, normalizing the vectors (or maybe not) and then doing a dot product to get a similarity value. 1 would mean they were exactly alike and -1 would mean they were negatively correlated so maybe take the absolute value of the dot product, if you want to count negative correlation as a strong similarity. Might work, might be problematic, not sure, but intuitively it feels like there's something there.

• Fourier transforms have a property called "unitarity", which means they preserve the canonical inner product. So the fancy FFT business is a lot of unnecessary work. You can calculate that exact same coefficient as an inner product in time domain. Apr 7, 2015 at 8:47
• Oh bummer. That makes sense after thinking about it a bit. I was hoping to remove the time component of the similarity comparison by taking it to frequency domain, but realize now that isn't what happens :p Apr 7, 2015 at 15:54

Your are looking for a method called matched filter.

something like sum(x(n)*y(n))/sqrt(sum(x(n)^2)*sum(y(n)^2)). this would give a 1 when x(n)=y(n)...

• sorry, but can I ask what the -1 means? Is there a problem with the validity of my answer or is just my use of brakets? Apr 9, 2015 at 7:15