Home > atmlab > circular > circ_otest.m

circ_otest

PURPOSE ^

SYNOPSIS ^

function [pval m] = circ_otest(alpha, sz, w)

DESCRIPTION ^

 [pval, m] = circ_otest(alpha,sz,w)
   Computes Omnibus or Hodges-Ajne test for non-uniformity of circular data.
   H0: the population is uniformly distributed around the circle
   HA: the population is not distributed uniformly around the circle

   Alternative to the Rayleigh and Rao's test. Works well for unimodal,
   bimodal or multimodal data. If requirements of the Rayleigh test are 
   met, the latter is more powerful.

   Input:
     alpha    sample of angles in radians
     [sz   step size for evaluating distribution, default 1 degree
     [w        number of incidences in case of binned angle data]

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

circ_otest.m

SOURCE CODE ^

0001 function [pval m] = circ_otest(alpha, sz, w)
0002 %
0003 % [pval, m] = circ_otest(alpha,sz,w)
0004 %   Computes Omnibus or Hodges-Ajne test for non-uniformity of circular data.
0005 %   H0: the population is uniformly distributed around the circle
0006 %   HA: the population is not distributed uniformly around the circle
0007 %
0008 %   Alternative to the Rayleigh and Rao's test. Works well for unimodal,
0009 %   bimodal or multimodal data. If requirements of the Rayleigh test are
0010 %   met, the latter is more powerful.
0011 %
0012 %   Input:
0013 %     alpha    sample of angles in radians
0014 %     [sz   step size for evaluating distribution, default 1 degree
0015 %     [w        number of incidences in case of binned angle data]
0016 
0017 %   Output:
0018 %     pval  p-value
0019 %     m     minimum number of samples falling in one half of the circle
0020 %
0021 % PHB 3/16/2009
0022 %
0023 % References:
0024 %   Biostatistical Analysis, J. H. Zar
0025 %   A bivariate sign test, J. L. Hodges et al., 1955
0026 %   A simple test for uniformity of a circular distribution, B. Ajne, 1968
0027 %
0028 % Circular Statistics Toolbox for Matlab
0029 
0030 % By Philipp Berens, 2009
0031 % berens@tuebingen.mpg.de - www.kyb.mpg.de/~berens/circStat.html
0032 
0033 if size(alpha,2) > size(alpha,1)
0034     alpha = alpha';
0035 end
0036 
0037 if nargin < 2 || isempty(sz)
0038   sz = circ_ang2rad(1);
0039 end
0040 
0041 if nargin < 3
0042   w = ones(size(alpha));
0043 else
0044   if length(alpha)~=length(w)
0045     error('Input length does not match.')
0046   end
0047   w =w(:);  
0048 end
0049 
0050 alpha = mod(alpha,2*pi);
0051 n = sum(w);
0052 dg = 0:sz:pi;
0053 
0054 m = zeros(size(dg));
0055 for i=1:length(dg)
0056   m(i) = sum((alpha > dg(i) & alpha < pi + dg(i)).*w);    
0057 end
0058 m = min(m);
0059 
0060 if n > 50
0061   % approximation by Ajne (1968)
0062   A = pi*sqrt(n) / 2 / (n-2*m);
0063   pval = sqrt(2*pi) / A * exp(-pi^2/8/A^2);
0064 else
0065   % exact formula by Hodges (1955)
0066   pval = 2^(1-n) * (n-2*m) * nchoosek(n,m);  
0067 end
0068 
0069   
0070   
0071 
0072 
0073 
0074 
0075 
0076 
0077 
0078 
0079

Generated on Mon 15-Sep-2014 13:31:28 by m2html © 2005