Home > atmlab > circular > circ_medtest.m

circ_medtest

PURPOSE ^

SYNOPSIS ^

function pval = circ_medtest(alpha,md)

DESCRIPTION ^

 [pval, z] = circ_medtest(alpha,w)
   Tests for significance of the median.
   H0: the population has median angle md
   HA: the population has not median angle md

   Input:
     alpha    sample of angles in radians
     md    median to test for

   Output:
     pval  p-value 

 PHB 3/19/2009

 References:
   Biostatistical Analysis, J. H. Zar, 27.4

 Circular Statistics Toolbox for Matlab

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

circ_medtest.m

SOURCE CODE ^

0001 function pval = circ_medtest(alpha,md)
0002 %
0003 % [pval, z] = circ_medtest(alpha,w)
0004 %   Tests for significance of the median.
0005 %   H0: the population has median angle md
0006 %   HA: the population has not median angle md
0007 %
0008 %   Input:
0009 %     alpha    sample of angles in radians
0010 %     md    median to test for
0011 %
0012 %   Output:
0013 %     pval  p-value
0014 %
0015 % PHB 3/19/2009
0016 %
0017 % References:
0018 %   Biostatistical Analysis, J. H. Zar, 27.4
0019 %
0020 % Circular Statistics Toolbox for Matlab
0021 
0022 % By Philipp Berens, 2009
0023 % berens@tuebingen.mpg.de - www.kyb.mpg.de/~berens/circStat.html
0024 
0025 if size(alpha,2) > size(alpha,1)
0026     alpha = alpha';
0027 end
0028 
0029 if length(md)>1
0030   error('Median can only be a single value.')
0031 end
0032 
0033 n = length(alpha);
0034 
0035 % compute deviations from median
0036 d = circ_dist(alpha,md);
0037 
0038 n1 = sum(d<0);
0039 n2 = sum(d>0);
0040 
0041 % compute p-value with binomial test
0042 pval = sum(binopdf([0:min(n1,n2) max(n1,n2):n],n,0.5));
0043 
0044 
0045 
0046

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