Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

docstrings of cross-correlation functions (acorr and xcorr) need clarification #1835

Copy link
Copy link
Closed
@pierre-haessig

Description

@pierre-haessig
Issue body actions

1) lags interpretation

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.

[1] http://mail.scipy.org/pipermail/numpy-discussion/2013-March/065839.html
[2] http://stat.ethz.ch/R-manual/R-patched/library/stats/html/acf.html
[3] http://www.mathworks.fr/fr/help/signal/ref/xcorr.html
[4] https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/axes.py#L4508

Metadata

Metadata

Assignees

No one assigned

    Labels

    Difficulty: Easyhttps://matplotlib.org/devdocs/devel/contribute.html#good-first-issueshttps://matplotlib.org/devdocs/devel/contribute.html#good-first-issuesDocumentation

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.