# How can I check similarity of two different sinusoidal waveform model?

I am trying to establish a similarity index for two different signals. These signals are quite different in amplitude and signal length. Their waveform is sinusoidal, and frequencies are at a close rate with each other. So, I would like to enter a similarity measure for them. How can I achieve this?

Here is the picture of them. • Can you show us a couple of these signals you're trying to get a similarity measure for?
– Jdip
Dec 25, 2022 at 1:01
• I shared a couple of examples @Jdip Dec 25, 2022 at 3:01

You mention signals of different amplitudes and lengths, but your example signals look the same lengths (or very close) and amplitudes (I'm talking about the range of course, not the actual amplitudes at each sample).

I'm not sure if you want to take amplitudes into account or if you're looking for something that does not for your similarity test, if you're interested in similarity of shape for example. In any case, here are my thoughts:

• Euclidean distance is straightforward. Do bear in mind it depends mostly on the amplitudes and time-shifts, which is great if you care about that, but terrible if you don't want these differences to be a factor.

• Pearson Correlation Coefficient, commonly defined $$r$$, gives you a similarity score $$0 \leq r \leq 1$$

Your example signals look the same lengths, or at least very close, in which case before calculating $$r$$ you can just truncate the largest signal to match the size of the smaller. This applies to any method that requires same-length inputs.

• Cross Correlation will give you a measure of similarity as a function of displacement of one signal relative to the other. You could compute that function and look for the max.

• Dynamic Time Warping measures similarity between two signals that can vary in speed. Bear in mind this algorithm has high complexity, especially for longer sequences.

• Coherence is a frequency domain approach that gives you a
linearity score at each frequency, i.e. how linearly related frequency components of one signal are to the frequency components in the other: $$0 \leq \texttt{coh}(f) \leq 1$$ One way to use this metric is to define a frequency range you're interested in and compute the average/median coherence value in that range. For better dynamic range you can take use a logarithmic scale: $$-\infty \leq 10\log_{10}(\texttt{coh}(f)) \leq 0$$

All of these methods have advantages/drawbacks depending on what you're interested in, and what your signals look like. You should experiment and see which or combination of which matches your needs.

• ED is generally terrible in time domain (though still worth knowing), there's more than amps & time-shifts but they're the main and simplest to my mind. Dec 25, 2022 at 10:01
• Thank you for the detailed answer @OverLordGoldDragon Dec 25, 2022 at 17:14
• @LunaLOVEGOOD Note it's Jdip's answer, I just made a small edit. Dec 26, 2022 at 7:37
• Then, thanks @Jdip Jan 1 at 14:48