circ_axialmean.m 903 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. function [r mu] = circ_axialmean(alphas, m, dim)
  2. %
  3. % mu = circ_axialmean(alpha, w)
  4. % Computes the mean direction for circular data with axial
  5. % correction.
  6. %
  7. % Input:
  8. % alpha sample of angles in radians
  9. % [m axial correction (2,3,4,...)]
  10. % [dim statistic computed along this dimension, 1]
  11. %
  12. % Output:
  13. % r mean resultant length
  14. % mu mean direction
  15. %
  16. % PHB 7/6/2008
  17. %
  18. % References:
  19. % Statistical analysis of circular data, N. I. Fisher
  20. % Topics in circular statistics, S. R. Jammalamadaka et al.
  21. % Biostatistical Analysis, J. H. Zar
  22. %
  23. % Circular Statistics Toolbox for Matlab
  24. % By Philipp Berens, 2009
  25. % berens@tuebingen.mpg.de - www.kyb.mpg.de/~berens/circStat.html
  26. % Distributed under Open Source BSD License
  27. if nargin < 3
  28. dim = 1;
  29. end
  30. if nargin < 2 || isempty(m)
  31. m = 1;
  32. end
  33. zbarm = mean(exp(i*alphas*m),dim);
  34. r = abs(zbarm);
  35. mu = angle(zbarm)/m;