You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
docstrings of cross-correlation functions (acorr and xcorr) need clarification #1835
Coming from a discussion on numpy mailing-list [1] I noticed an ambiguity in the interpretation of the sign of the lags in plt.xcorr cross-correlation function. In R's acf/ccf documentation [2] there is the following notice :
The lag k value returned by ccf(x, y) estimates the correlation between x[t+k] and y[t].
I think that xcorr uses the same convention (like Matlab [3]) so we should put some similar notice. (note that this does not seem to be a universal definition. On Wikipedia cross-correlation page, the definition mentions x[t] * y[t+k] instead)
2) normed argument
In addition, the definition of the normed argument seems weird:
If normed = True, normalize the data by the cross correlation at 0-th lag
I think this is not what is computed [4]:
if normed:
c /= np.sqrt(np.dot(x, x) * np.dot(y, y))
Maybe the acorr definition of normalization also needs so fine tuning because it's somehow recursive.
Activity
tacaswell commentedon Aug 17, 2014
@pierre-haessig I know this is old, but want to take a crack at updating the docstrings?
story645 commentedon May 31, 2016
Note, these are the current docs: xcorr, acorr
Merge pull request #7470 from dstansby/correlation-docstrings
Merge pull request #7470 from dstansby/correlation-docstrings
dstansby commentedon Jan 2, 2017
Fixed by my PR (I think), but I forgot to put "fixes" in the description, could someone manually close this?