circ_skewness.m 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. function [b b0] = circ_skewness(alpha, w, dim)
  2. % [b b0] = circ_skewness(alpha,w,dim)
  3. % Calculates a measure of angular skewness.
  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_skewness(alpha, [], dim)
  12. %
  13. % Output:
  14. % b skewness (from Pewsey)
  15. % b0 alternative skewness measure (from Fisher)
  16. %
  17. % References:
  18. % Pewsey, Metrika, 2004
  19. % Statistical analysis of circular data, Fisher, 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 neccessary values
  37. R = circ_r(alpha,w,[],dim);
  38. theta = circ_mean(alpha,w,dim);
  39. [foo rho2 mu2] = circ_moment(alpha,w,2,true,dim);
  40. % compute skewness
  41. theta2 = repmat(theta, size(alpha)./size(theta));
  42. b = sum(w.*(sin(2*(circ_dist(alpha,theta2)))),dim)./sum(w,dim);
  43. b0 = rho2.*sin(circ_dist(mu2,2*theta))./(1-R).^(3/2); % (formula 2.29)