# How to compare and measure the similarity between two between two signals?

I'm working on different sensors data, the question is this: I have two signals (coming from two different sensors measuring two different phisical charactheristcs of the same "object"). I know for a fact that there is a certain amount of time delay between the two signals, but beyond that, I just want to know how is the correct procedure to correlate the two signals in order to have a proper idea of the similiarity of the signals. Moreover: Can I modify the signal sens1 in order to predict (if in real time or in order to get in post-processing) the signal sens2? Is any specific tool or package in python to easily do this type of comparison?

BR

The DTW approach is applicable to signals where there is an acceleration or deceleration between the observations of similar signals during the data capture and will show how similar or not the signals are besides the distortion from the "time-warping".

I am not sure that would be the best approach for this case given nothing is indicating there will be a change in the rate of time between the sensors (although to a second order the sampling clock in one will not be exactly matched to the sampling clock in the other so DTW could be useful if the sampling clock offset exceeded the coherence bandwidth of the capture, which is $$1/T$$ where $$T$$ is the length of the capture for which we will use correlation, which I will describe next).

This looks like an ideal application for the cross correlation function, which will show the correlation between the two waveforms for every time offset between the two. This is done by first removing the mean from each waveform, and then multiplying the two resulting zero-mean waveforms together element by element and summing the result, repeating for each possible sample shift between the waveforms. These results can be scaled by the product of the standard deviation of the two waveforms, which would normalize the result similar to what is done in the Pearson correlation coefficient.

Another similar approach is to use the Wiener-Hopf equations to solve for the equivalent "channel" between the two waveforms, which I have explained in more detail at this post which evaluated the signal received by two microphones:

• thanks, I found your comment very interesting, I will have a better look at your link to the use of Wiener-Hopf; I need some time to digest it. Thanks – Luca R Feb 10 '20 at 16:46

For measuring the similarity between two temporal signals, you can try using Dynamic Time Warping (DTW). DTW constructs a distance matrix between the two signals and tries to find minimum distance the two signals. If the two signals are identical, then distance is zero.

The answer to your second questions depends on the signal model used to generate these signals. It is not clear from the question how the signals from sensor #1 and #2 are generated.

• HI Maxtron, thanks for the help; I'm taking some time to look at the DTW technique, it seems to be useful in my case. I still have a doubt: should I use some preprocessing before the use of the DTW algorithm? For example, my signals have so different values in amplitude, is this a possible issue in the DTW tecnique? Which are the right steps to proper apply this class of algorithms? – Luca R Sep 13 '19 at 7:43
• I don't know what type of system you are modeling here. So, I cannot suggest the best preprocessing strategy. – Maxtron Sep 13 '19 at 15:21