Scheduled service maintenance on November 22


On Friday, November 22, 2024, between 06:00 CET and 18:00 CET, GIN services will undergo planned maintenance. Extended service interruptions should be expected. We will try to keep downtimes to a minimum, but recommend that users avoid critical tasks, large data uploads, or DOI requests during this time.

We apologize for any inconvenience.

circ_corrcc.m 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. function [rho pval] = circ_corrcc(alpha1, alpha2)
  2. %
  3. % [rho pval ts] = circ_corrcc(alpha1, alpha2)
  4. % Circular correlation coefficient for two circular random variables.
  5. %
  6. % Input:
  7. % alpha1 sample of angles in radians
  8. % alpha2 sample of angles in radians
  9. %
  10. % Output:
  11. % rho correlation coefficient
  12. % pval p-value
  13. %
  14. % References:
  15. % Topics in circular statistics, S.R. Jammalamadaka et al., p. 176
  16. %
  17. % PHB 6/7/2008
  18. %
  19. % Circular Statistics Toolbox for Matlab
  20. % By Philipp Berens, 2009
  21. % berens@tuebingen.mpg.de - www.kyb.mpg.de/~berens/circStat.html
  22. if size(alpha1,2) > size(alpha1,1)
  23. alpha1 = alpha1';
  24. end
  25. if size(alpha2,2) > size(alpha2,1)
  26. alpha2 = alpha2';
  27. end
  28. if length(alpha1)~=length(alpha2)
  29. error('Input dimensions do not match.')
  30. end
  31. % compute mean directions
  32. n = length(alpha1);
  33. alpha1_bar = circ_mean(alpha1);
  34. alpha2_bar = circ_mean(alpha2);
  35. % compute correlation coeffcient from p. 176
  36. num = sum(sin(alpha1 - alpha1_bar) .* sin(alpha2 - alpha2_bar));
  37. den = sqrt(sum(sin(alpha1 - alpha1_bar).^2) .* sum(sin(alpha2 - alpha2_bar).^2));
  38. rho = num / den;
  39. % compute pvalue
  40. l20 = mean(sin(alpha1 - alpha1_bar).^2);
  41. l02 = mean(sin(alpha2 - alpha2_bar).^2);
  42. l22 = mean((sin(alpha1 - alpha1_bar).^2) .* (sin(alpha2 - alpha2_bar).^2));
  43. ts = sqrt((n * l20 * l02)/l22) * rho;
  44. pval = 2 * (1 - normcdf(abs(ts)));