1
$\begingroup$

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. enter image description here

I really appreciate any help you can provide

$\endgroup$
2
  • 1
    $\begingroup$ Can you show us a couple of these signals you're trying to get a similarity measure for? $\endgroup$
    – Jdip
    Dec 25, 2022 at 1:01
  • $\begingroup$ I shared a couple of examples @Jdip $\endgroup$ Dec 25, 2022 at 3:01

1 Answer 1

2
$\begingroup$

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.

$\endgroup$
4
  • $\begingroup$ 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. $\endgroup$ Dec 25, 2022 at 10:01
  • $\begingroup$ Thank you for the detailed answer @OverLordGoldDragon $\endgroup$ Dec 25, 2022 at 17:14
  • 2
    $\begingroup$ @LunaLOVEGOOD Note it's Jdip's answer, I just made a small edit. $\endgroup$ Dec 26, 2022 at 7:37
  • $\begingroup$ Then, thanks @Jdip $\endgroup$ Jan 1, 2023 at 14:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.