np.correlate() am trying to find the lag position of two data sets of different length.
When I use this operation by its own I find a lag position between my two data sets of 957. However when i implement a normalized cross correlation this changes to a lag of 1126. Can anyone explain why this is the case I would expect them to give the same lag.
My code for finding the lag in the "normal" cross correlation is:
corrs = np.correlate(a, b, mode="full") # a and b are pandas DataFrames lag = (corrs.argmax() - corrs.size/2)
For the normalised correlation:
a = (a - np.mean(a)) / (np.std(a) * len(a) b = (b - np.mean(b)) / (np.std(b) norm_corrs = np.correlate(a, b, mode="full") lag_norm = (norm_corrs.argmax() - norm_corrs.size/2)
In my case i get lag = 9 and lag_norm = 178!
Any pointers would be Great!