Home > atmlab > circular > circ_ktest.m

circ_ktest

PURPOSE ^

[pval, f] = circ_ktest(alpha1, alpha2)

SYNOPSIS ^

function [pval, f] = circ_ktest(alpha1, alpha2)

DESCRIPTION ^

 [pval, f] = circ_ktest(alpha1, alpha2)

 A parametric two-sample test to determine whether two concentration 
 parameters are different.  
 
   H0: The two concentration parameters are equal.
   HA: The two concentration parameters are different.

 Input: 
   alpha1     fist sample (in radians)
   alpha2     second sample (in radians)

 Output:
   pval        p-value that samples have different concentrations
   f           f-statistic calculated

 Assumptions: both samples are drawn from von Mises type distributions
              and their joint resultant vector length should be > .7
 
 References:
   Batschelet, 1980, section 6.9, pg 122-124

 Circular Statistics Toolbox for Matlab

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

circ_ktest.m

SOURCE CODE ^

0001 function [pval, f] = circ_ktest(alpha1, alpha2)
0002 % [pval, f] = circ_ktest(alpha1, alpha2)
0003 %
0004 % A parametric two-sample test to determine whether two concentration
0005 % parameters are different.
0006 %
0007 %   H0: The two concentration parameters are equal.
0008 %   HA: The two concentration parameters are different.
0009 %
0010 % Input:
0011 %   alpha1     fist sample (in radians)
0012 %   alpha2     second sample (in radians)
0013 %
0014 % Output:
0015 %   pval        p-value that samples have different concentrations
0016 %   f           f-statistic calculated
0017 %
0018 % Assumptions: both samples are drawn from von Mises type distributions
0019 %              and their joint resultant vector length should be > .7
0020 %
0021 % References:
0022 %   Batschelet, 1980, section 6.9, pg 122-124
0023 %
0024 % Circular Statistics Toolbox for Matlab
0025 
0026 % By Marc J. Velasco, 2009
0027 % velasco@ccs.fau.edu
0028 
0029 alpha1 = alpha1(:);
0030 alpha2 = alpha2(:);
0031 
0032 n1 = length(alpha1);
0033 n2 = length(alpha2);
0034 
0035 R1 = n1*circ_r(alpha1);
0036 R2 = n2*circ_r(alpha2);
0037 
0038 % make sure that rbar > .7
0039 rbar = (R1+R2)/(n1+n2);
0040 
0041 if rbar < .7
0042     warning('resultant vector length should be > 0.7') %#ok<WNTAG>
0043 end
0044 
0045 % calculate test statistic
0046 f = ((n2-1)*(n1-R1))/((n1-1)*(n2-R2));
0047 if f > 1
0048   pval = 2*(1-fcdf(f, n1, n2));
0049 else
0050   f = 1/f; 
0051   pval = 2*(1-fcdf(f, n2, n1));
0052 end
0053 
0054 
0055 
0056 
0057 
0058 
0059

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