归一化互相关(转自https://anomaly.io/understand-auto-cross-correlation-normalized-shift/index.html)

Normalized Cross-Correlation

归一化互相关(转)
There are three problems with cross-correlation:

It is difficult to understand the scoring value.
Both metrics must have the same amplitude. If Graph B has the same shape as Graph A but values two times smaller, the correlation will not be detected.
corr(a, a/2) = 19.5
Due to the formula, a zero value will not be taken into account, since 00=0 and 0200=0.
To solve these problems we use normalized cross-correlation:

norm_corr(x,y)=n=0n1x[n]y[n]n=0n1x[n]2n=0n1y[n]2norm\_corr(x,y)=\dfrac{\sum_{n=0}^{n-1} x[n]*y[n]}{\sqrt{\sum_{n=0}^{n-1} x[n]^2 * \sum_{n=0}^{n-1} y[n]^2}}

Using this formula let’s compute the normalized cross-correlation of AB and AC.

norm_corr(a,b)=12+23+22+43+22+34+11+01(1+4+4+16+4+9+1+0)(4+9+4+9+4+16+1+1)=41(39)(48)=0.947norm\_corr(a,b) = \dfrac{1*2+2*3+-2*-2+4*3+2*2+3*4+1*1+0*-1}{\sqrt{(1+4+4+16+4+9+1+0)*(4+9+4+9+4+16+1+1)}} \\ = \dfrac{41}{\sqrt{(39)*(48)}} \\ = 0.947

norm_corr(a,c)=12+20+24+40+21+31+10+02(1+4+4+16+4+9+1+0)(4+0+16+0+1+1+0+4)=5(39)(26)=0.157norm\_corr(a,c) =\dfrac{1*-2+2*0+-2*4+4*0+2*1+3*1+1*0+0*-2}{\sqrt{(1+4+4+16+4+9+1+0)*(4+0+16+0+1+1+0+4)}} \\ =\dfrac{-5}{\sqrt{(39)*(26)}} \\ =-0.157

Graphs A and B correlate, with a high value of 0.947.
Graphs A and C don’t correlate, showing a low value of -0.157.

Normalized cross-correlation scoring is easy to understand:
– The higher the value, the higher the correlation is.
– The maximum value is 1 when two signals are exactly the same:
norm_corr(a,a)=1
– The minimum value is -1 when two signals are exactly opposite:
norm_corr(a, -a) = -1
Normalized cross-correlation can detect the correlation of two signals with different amplitudes: norma_corr(a, a/2) = 1.
Notice we have perfect correlation between signal A and the same signal with half the amplitude!

相关文章: