circ_mtest.m 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. function [h mu ul ll] = circ_mtest(alpha, dir, xi, w, d)
  2. %
  3. % [pval, z] = circ_mtest(alpha, dir, w, d)
  4. % One-Sample test for the mean angle.
  5. % H0: the population has mean dir.
  6. % HA: the population has not mean dir.
  7. %
  8. % Note: This is the equvivalent to a one-sample t-test with specified
  9. % mean direction.
  10. %
  11. % Input:
  12. % alpha sample of angles in radians
  13. % dir assumed mean direction
  14. % [xi alpha level of the test]
  15. % [w number of incidences in case of binned angle data]
  16. % [d spacing of bin centers for binned data, if supplied
  17. % correction factor is used to correct for bias in
  18. % estimation of r, in radians (!)]
  19. %
  20. % Output:
  21. % h 0 if H0 can not be rejected, 1 otherwise
  22. % mu mean
  23. % ul upper (1-xi) confidence level
  24. % ll lower (1-xi) confidence level
  25. %
  26. % PHB 7/6/2008
  27. %
  28. % References:
  29. % Biostatistical Analysis, J. H. Zar
  30. %
  31. % Circular Statistics Toolbox for Matlab
  32. % By Philipp Berens, 2009
  33. % berens@tuebingen.mpg.de - www.kyb.mpg.de/~berens/circStat.html
  34. if size(alpha,2) > size(alpha,1)
  35. alpha = alpha';
  36. end
  37. if nargin<3
  38. xi = 0.05;
  39. end
  40. if nargin<4
  41. % if no specific weighting has been specified
  42. % assume no binning has taken place
  43. w = ones(size(alpha));
  44. else
  45. if size(w,2) > size(w,1)
  46. w = w';
  47. end
  48. if length(alpha)~=length(w)
  49. error('Input dimensions do not match.')
  50. end
  51. end
  52. if nargin<5
  53. % per default do not apply correct for binned data
  54. d = 0;
  55. end
  56. % compute ingredients
  57. mu = circ_mean(alpha,w);
  58. t = circ_confmean(alpha,xi,w,d);
  59. ul = mu + t;
  60. ll = mu - t;
  61. % compute test via confidence limits (example 27.3)
  62. h = abs(circ_dist2(dir,mu)) > t;