-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
trouble with correlation #79
Comments
It's also not what I would expect - I need to see whether I find time to debug it. Is there a chance you can run the Matlab version if it yields the same? |
That would be great :) Unfortunately, I don't have a Matlab license |
the current implementation (Jammalamadaka & SenGupta, 2001) subtracts the mean out of the original data, then compute the correlation, which turns out to be problematic for your data, because ts1 is more or less uniformly distributed, while ts2 is bimodal (more accurately, axial). here's an alternative implementation (Fisher & Lee, 1983; Zar, 1999) without mean subtraction that can give you a def aacorr(a: np.ndarray, b: np.ndarray) -> float:
"""Fisher & Lee (1983); Zar (1999) eq (27.43)
a, b: np.array, (n, )
circular data in radian
raa: float
angular-angular correlation
"""
aij = np.triu(a[: ,None] - a).flatten()
bij = np.triu(b[: ,None] - b).flatten()
num = np.sum(np.sin(aij) * np.sin(bij))
den = np.sqrt(np.sum(np.sin(aij) ** 2) * np.sum(np.sin(bij) ** 2))
raa = num / den
return raa |
Hi David, |
Hi guys, thanks for this lovely repo!
I am having trouble with circular correlation between two circular variables. As you can see they are strongly correlated, but the correlation function returns nearly 0:
Here are the two signals if you want to try it:
timeseries: 1, 2
Is there a problem with the code or am I doing sth wrong?
The text was updated successfully, but these errors were encountered: