circ_kurtosis.m 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. function [k k0] = circ_kurtosis(alpha, w, dim)
  2. % [k k0] = circ_kurtosis(alpha,w,dim)
  3. % Calculates a measure of angular kurtosis.
  4. %
  5. % Input:
  6. % alpha sample of angles
  7. % [w weightings in case of binned angle data]
  8. % [dim statistic computed along this dimension, 1]
  9. %
  10. % If dim argument is specified, all other optional arguments can be
  11. % left empty: circ_kurtosis(alpha, [], dim)
  12. %
  13. % Output:
  14. % k kurtosis (from Pewsey)
  15. % k0 kurtosis (from Fisher)
  16. %
  17. % References:
  18. % Pewsey, Metrika, 2004
  19. % Fisher, Circular Statistics, p. 34
  20. %
  21. % Circular Statistics Toolbox for Matlab
  22. % By Philipp Berens, 2009
  23. % berens@tuebingen.mpg.de
  24. if nargin < 3
  25. dim = 1;
  26. end
  27. if nargin < 2 || isempty(w)
  28. % if no specific weighting has been specified
  29. % assume no binning has taken place
  30. w = ones(size(alpha));
  31. else
  32. if size(w,2) ~= size(alpha,2) || size(w,1) ~= size(alpha,1)
  33. error('Input dimensions do not match');
  34. end
  35. end
  36. % compute mean direction
  37. R = circ_r(alpha,w,[],dim);
  38. theta = circ_mean(alpha,w,dim);
  39. [foo rho2] = circ_moment(alpha,w,2,true,dim);
  40. [foo foo2 mu2] = circ_moment(alpha,w,2,false,dim);
  41. % compute skewness
  42. theta2 = repmat(theta, size(alpha)./size(theta));
  43. k = sum(w.*(cos(2*(circ_dist(alpha,theta2)))),dim)./sum(w,dim);
  44. k0 = (rho2.*cos(circ_dist(mu2,2*theta))-R.^4)./(1-R).^2; % (formula 2.30)