Home > atmlab > circular > circ_rtest.m

circ_rtest

PURPOSE ^

SYNOPSIS ^

function [pval z] = circ_rtest(alpha, w, d)

DESCRIPTION ^

 [pval, z] = circ_rtest(alpha,w)
   Computes Rayleigh test for non-uniformity of circular data.
   H0: the population is uniformly distributed around the circle
   HA: the populatoin is not distributed uniformly around the circle
   Assumption: the distribution has maximally one mode and the data is 
   sampled from a von Mises distribution!

   Input:
     alpha    sample of angles in radians
     [w        number of incidences in case of binned angle data]
     [d    spacing of bin centers for binned data, if supplied 
           correction factor is used to correct for bias in 
           estimation of r, in radians (!)]

   Output:
     pval  p-value of Rayleigh's test
     z     value of the z-statistic

 PHB 7/6/2008

 References:
   Statistical analysis of circular data, N. I. Fisher
   Topics in circular statistics, S. R. Jammalamadaka et al. 
   Biostatistical Analysis, J. H. Zar

 Circular Statistics Toolbox for Matlab

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

circ_rtest.m

SOURCE CODE ^

0001 function [pval z] = circ_rtest(alpha, w, d)
0002 %
0003 % [pval, z] = circ_rtest(alpha,w)
0004 %   Computes Rayleigh test for non-uniformity of circular data.
0005 %   H0: the population is uniformly distributed around the circle
0006 %   HA: the populatoin is not distributed uniformly around the circle
0007 %   Assumption: the distribution has maximally one mode and the data is
0008 %   sampled from a von Mises distribution!
0009 %
0010 %   Input:
0011 %     alpha    sample of angles in radians
0012 %     [w        number of incidences in case of binned angle data]
0013 %     [d    spacing of bin centers for binned data, if supplied
0014 %           correction factor is used to correct for bias in
0015 %           estimation of r, in radians (!)]
0016 %
0017 %   Output:
0018 %     pval  p-value of Rayleigh's test
0019 %     z     value of the z-statistic
0020 %
0021 % PHB 7/6/2008
0022 %
0023 % References:
0024 %   Statistical analysis of circular data, N. I. Fisher
0025 %   Topics in circular statistics, S. R. Jammalamadaka et al.
0026 %   Biostatistical Analysis, J. H. Zar
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
0038     r =  circ_r(alpha);
0039   n = length(alpha);
0040 else
0041   if length(alpha)~=length(w)
0042     error('Input dimensions do not match.')
0043   end
0044   if nargin < 3
0045     d = 0;
0046   end
0047   r =  circ_r(alpha,w(:),d);
0048   n = sum(w);
0049 end
0050 
0051 % compute Rayleigh's R (equ. 27.1)
0052 R = n*r;
0053 
0054 % compute Rayleigh's z (equ. 27.2)
0055 z = R^2 / n;
0056 
0057 % compute p value using approxation in Zar, p. 617
0058 pval = exp(sqrt(1+4*n+4*(n^2-R^2))-(1+2*n));
0059 
0060 % outdated version:
0061 % compute the p value using an approximation from Fisher, p. 70
0062 % pval = exp(-z);
0063 % if n < 50
0064 %   pval = pval * (1 + (2*z - z^2) / (4*n) - ...
0065 %    (24*z - 132*z^2 + 76*z^3 - 9*z^4) / (288*n^2));
0066 % end
0067 
0068 
0069 
0070 
0071 
0072 
0073 
0074 
0075

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