# How can define an indicator which measures the degree of similarity between two signals?

The similarity of two signals is calculated by cross correlation. But, how to define an indicator which quantitatively measures the degree of similarity between two signals? Thanks.

• normalize your cross correlation, Stephan. – robert bristow-johnson Oct 22 '16 at 3:20
• Can you clarify what it is that you need that is not provided by correlation? – MBaz Oct 22 '16 at 3:21

assuming finite power signals:

$$\lVert x \rVert^2 \triangleq \lim_{N \to \infty} \ \frac{1}{2N+1} \sum\limits_{n=-N}^{+N} \big|x[n] \big|^2 \ < +\infty$$

this is a Hilbert Space sorta thingie.

define inner product:

$$\langle x,y \rangle \triangleq \lim_{N \to \infty} \ \frac{1}{2N+1} \sum\limits_{n=-N}^{+N} x[n] \cdot \overline{y}[n]$$

where $\overline{y}[n]$ is the complex conjugate of $y[n]$. so this is true about the norm:

$$\lVert x \rVert = \sqrt{\langle x, x \rangle}$$

Cross-Correlation:

$$R_{xy}[k] \triangleq \langle x[n], y[n+k] \rangle$$

Autoorrelation:

$$R_{xx}[k] \triangleq \langle x[n], x[n+k] \rangle \ \le R_{xx}[0] = \lVert x \rVert^2$$

Normalized Autocorrelation (sometimes called "autocovariance")

$$-1 \le \frac{R_{xx}[k]}{R_{xx}[0]} \triangleq \frac{\langle x[n], x[n+k] \rangle}{\langle x[n], x[n] \rangle} \ \le 1$$

Normalized Crosscorrelation:

$$-1 \le \frac{R_{xy}[k]}{\lVert x \rVert \lVert y \rVert} \triangleq \frac{\langle x[n], y[n+k] \rangle}{\sqrt{\langle x[n], x[n] \rangle}\sqrt{\langle y[n], y[n] \rangle}} \ \le 1$$

• Dear @robertbristow-johnson, thanks for your nice solution. – Amin Oct 22 '16 at 4:02
• just a mistake. Excuse me. – Amin Oct 22 '16 at 4:03

The general topic of finding similarities between signals is wide ranging:

• are the signals of same sampling, length, offset, shift or scale?
• where do they take their values (discrete, real, complex)?
• are they stationary? noisy?
• what do you consider similar (whole signals, chunks, specific features)?
• which are the invariances looked for?
• and most important: what is your goal?

The following works provide an overview of some common similarity metrics, which one can normalize into an index:

• This is called a useful answer. – msm Oct 22 '16 at 6:44
• Dear @Laurent Duval, thanks for your nice answer. – Amin Oct 22 '16 at 12:42

if you are searching for similarity between two signals in frequency domain, you can go for coherence. Coherence indicates frequency components common to both signals