# Cross Correlation shows peak at the same location every time

I have a signal which is taken from an accelerometer and I'm trying to match patterns between different windows of the signal by cross correlation. To do this I take different windows of the signal, sliding it on the signal and taking cross correlation and I'm hopping to find similarity between different windows by finding the peaks of my cross correlation. However what I see is that no matter what window of the signal I use, I get peaks on some specific points on my signal! I usually don't even get peaks on the point where the window itself was taken from. My first observation was that the peak points were located on noisy parts of the signal were the signal had a high magnitude nearby (which was an outlier compared to the rest of the signal.) So I did a preprocessing and removed the outliers. But I still get the same result on some other points on the signal. I also use the following formula for cross correlation:

$$r=\frac{\sum_i[x(i)-\mu_x]\times[y(i-d)-\mu_y]}{\sqrt{\sum_i(x(i)-\mu_x)^2}\times\sqrt{\sum_i(y(i-d)-\mu_x)^2}}$$

So the signals have a mean on 0 and cross correlation is normalized by their standard deviation. So the questions I have are what am I doing wrong and how can I fix this? maybe additional preprocessing or an alteration in my formula? How can I know if cross correlation is a suitable similarity measure for my task or not? What other alternative methods do you suggest?

Additional Information: I used this python implementation of cross correlation in my code. I also post an image of my signal and points which have high correlation with nearly every window. In this image the red curve is my signal. The two windows which show strong correlation to other windows dosn't look to have any special characteristics (high magnitude, etc).

• do you need to find out when is your signal(accelerometer data) repeating itself ? can you please tell what is that you want to do after matching, that might help in suggesting you. – arpit jain Dec 25 '16 at 7:29
• I'm somehow trying to do unsupervised learning on this signal. I'm trying to find similarity in different parts of the signal (which is a time series) so I can argue that the recording of accelerometer at those times show a meaningful activity (Not a random one). If I find this correlation between some parts of my signal, then I can extract discriminating features from those parts or perhaps train a correlation filter. – user3597574 Dec 25 '16 at 13:48