Created
March 6, 2019 19:30
-
-
Save jcheong0428/6f6360432b0133e8192a899042f3b202 to your computer and use it in GitHub Desktop.
Cross Correlation Function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def crosscorr(datax, datay, lag=0): | |
""" Lag-N cross correlation. | |
Calculates cross correlations using pandas functionality that can be used in a list comprehension. | |
Parameters | |
---------- | |
lag : int, default 0 | |
datax, datay : pandas.Series objects of equal length | |
Returns | |
---------- | |
crosscorr : float | |
Examples | |
---------- | |
rs = [crosscorr(d1,d2, lag) for lag in range(-60,61)] | |
""" | |
return datax.corr(datay.shift(lag)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment