1
$\begingroup$

I have two signals in the time domain, call them $S_1(t)$ and $S_2$(t). Because of calibration issues relating to the underlying devices that these signals are obtained from, they will not necessarily have the same scale or mean. What is the appropriate way to compute a measure of similarity such that, if $S_2(t)$=$C_1 * S_1(t) + C_2$, where $C_1$ and $C_2$ are constants, my measure of similarity will say that these signals are identical? Or at least indicates that they are very similar?

Edit: The solution provided by Digiproc is indeed a good solution to the problem as I originally stated it. However, it seems that I simplified my original problem too much for this question and that their solution would not work in my case. In particular, one of my signals has noisy spiky behavior in addition (i.e., very sharp and large localized peaks due to sensor technical issues). Therefore the dividing of one of the samples by the sample magnitude is not going to lead to a good alignment of the two signals. Is the MSE difference approach mentioned by robert-bristow-johnson in the comment the best approach then?

$\endgroup$
  • $\begingroup$ there is a pretty straight-forward way of finding $C_1$ and $C_2$ to minimize the mean square difference between $S_2(t)$ and $C_1 S_1(t)+C_2$. $\endgroup$ – robert bristow-johnson Sep 18 '17 at 6:44
  • $\begingroup$ Thank you, @robert-bristow-johnson. I accidentally undid my upvote of your comment, so am unable to upvote it again. But so far your solution is the best for my actual problem (which wasn't stated well in my original question). If this answer remains the best, feel free to add it as an answer. $\endgroup$ – gammapoint Sep 18 '17 at 14:51
  • $\begingroup$ Or maybe using a Pearson correlation coefficient would make more sense? It's invariant to transformations of the type Ax+B. $\endgroup$ – gammapoint Sep 18 '17 at 17:23
2
$\begingroup$

First remove the DC offset (C2) from each signal by subtracting the average level from each sample, then removing the arbitrary scaling (C1) of each signal by dividing each sample by the average sample magnitude.

$\endgroup$
  • 1
    $\begingroup$ I agree on the method, although the average of the samples of $S_1$ is not necessarily equal to $C_2$. Furthermore, the last step, i.e., the computation of a similarity measure, is missing. A straightforward approach would be to compute the mean squared error after offset removal and level matching: $e=\frac{1}{N}\sum_{i=0}^{N-1}(S_1^\prime[i]-S_2^\prime[i])^2$ with $S_1^\prime$ and $S_2^\prime$ the normalized signals. $\endgroup$ – applesoup Sep 18 '17 at 4:17
  • $\begingroup$ Thanks for the comments Digiproc and @applesoup. The approach you describe would indeed work for my problem as stated. However, I've updated my question because I oversimplified my actual problem and I don't think your approach would work in my particular case. $\endgroup$ – gammapoint Sep 18 '17 at 14:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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