Home > atmlab > circular > circ_confmean.m

circ_confmean

PURPOSE ^

SYNOPSIS ^

function t = circ_confmean(alpha, xi, w, d, dim)

DESCRIPTION ^

 t = circ_mean(alpha, xi, w, d, dim)
   Computes the confidence limits on the mean for circular data.

   Input:
     alpha    sample of angles in radians
     [xi   (1-xi)-confidence limits are computed, default 0.05]
     [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 (!)]
     [dim  compute along this dimension, default is 1]

   Output:
     t     mean +- d yields upper/lower (1-xi)% confidence limit

 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_confmean.m

SOURCE CODE ^

0001 function t = circ_confmean(alpha, xi, w, d, dim)
0002 %
0003 % t = circ_mean(alpha, xi, w, d, dim)
0004 %   Computes the confidence limits on the mean for circular data.
0005 %
0006 %   Input:
0007 %     alpha    sample of angles in radians
0008 %     [xi   (1-xi)-confidence limits are computed, default 0.05]
0009 %     [w        number of incidences in case of binned angle data]
0010 %     [d    spacing of bin centers for binned data, if supplied
0011 %           correction factor is used to correct for bias in
0012 %           estimation of r, in radians (!)]
0013 %     [dim  compute along this dimension, default is 1]
0014 %
0015 %   Output:
0016 %     t     mean +- d yields upper/lower (1-xi)% confidence limit
0017 %
0018 % PHB 7/6/2008
0019 %
0020 % References:
0021 %   Statistical analysis of circular data, N. I. Fisher
0022 %   Topics in circular statistics, S. R. Jammalamadaka et al.
0023 %   Biostatistical Analysis, J. H. Zar
0024 %
0025 % Circular Statistics Toolbox for Matlab
0026 
0027 % By Philipp Berens, 2009
0028 % berens@tuebingen.mpg.de - www.kyb.mpg.de/~berens/circStat.html
0029 
0030 if nargin < 5
0031   dim = 1;
0032 end
0033 
0034 if nargin < 4 || isempty(d)
0035   % per default do not apply correct for binned data
0036   d = 0;
0037 end
0038 
0039 if nargin < 3 || isempty(w)
0040   % if no specific weighting has been specified
0041   % assume no binning has taken place
0042     w = ones(size(alpha));
0043 else
0044   if size(w,2) ~= size(alpha,2) || size(w,1) ~= size(alpha,1) 
0045     error('Input dimensions do not match');
0046   end 
0047 end
0048 
0049 % set confidence limit size to default
0050 if nargin < 2 || isempty(xi)
0051   xi = 0.05;
0052 end
0053 
0054 % compute ingredients for conf. lim.
0055 r = circ_r(alpha,w,d,dim);
0056 n = sum(w,dim);
0057 R = n.*r;
0058 c2 = chi2inv((1-xi),1);
0059 
0060 % check for resultant vector length and select appropriate formula
0061 t = zeros(size(r));
0062 
0063 for i = 1:numel(r)
0064   if r(i) < .9 && r(i) > sqrt(c2/2/n(i))
0065     t(i) = sqrt((2*n(i)*(2*R(i)^2-n(i)*c2))/(4*n(i)-c2));  % equ. 26.24
0066   elseif r(i) >= .9
0067     t(i) = sqrt(n(i)^2-(n(i)^2-R(i)^2)*exp(c2/n(i)));      % equ. 26.25
0068   else 
0069     t(i) = NaN;
0070     warning('Requirements for confidence levels not met.');
0071   end
0072 end
0073 
0074 % apply final transform
0075 t = acos(t./R);
0076   
0077 
0078 
0079

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