Home > atmlab > circular > circ_var.m

circ_var

PURPOSE ^

s = circ_var(alpha, w, d, dim)

SYNOPSIS ^

function [S s] = circ_var(alpha, w, d, dim)

DESCRIPTION ^

 s = circ_var(alpha, w, d, dim)
   Computes circular variance for circular data 
   (equ. 26.17/18, Zar).   

   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]
     [dim  compute along this dimension, default is 1]

     If dim argument is specified, all other optional arguments can be
     left empty: circ_var(alpha, [], [], dim)

   Output:
     S     circular variance 1-r
     s     angular variance 2*(1-r)

 PHB 6/7/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_var.m

SOURCE CODE ^

0001 function [S s] = circ_var(alpha, w, d, dim)
0002 % s = circ_var(alpha, w, d, dim)
0003 %   Computes circular variance for circular data
0004 %   (equ. 26.17/18, Zar).
0005 %
0006 %   Input:
0007 %     alpha    sample of angles in radians
0008 %     [w        number of incidences in case of binned angle data]
0009 %     [d    spacing of bin centers for binned data, if supplied
0010 %           correction factor is used to correct for bias in
0011 %           estimation of r]
0012 %     [dim  compute along this dimension, default is 1]
0013 %
0014 %     If dim argument is specified, all other optional arguments can be
0015 %     left empty: circ_var(alpha, [], [], dim)
0016 %
0017 %   Output:
0018 %     S     circular variance 1-r
0019 %     s     angular variance 2*(1-r)
0020 %
0021 % PHB 6/7/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 nargin < 4
0034   dim = 1;
0035 end
0036 
0037 if nargin < 3 || isempty(d)
0038   % per default do not apply correct for binned data
0039   d = 0;
0040 end
0041 
0042 if nargin < 2 || isempty(w)
0043   % if no specific weighting has been specified
0044   % assume no binning has taken place
0045     w = ones(size(alpha));
0046 else
0047   if size(w,2) ~= size(alpha,2) || size(w,1) ~= size(alpha,1) 
0048     error('Input dimensions do not match');
0049   end 
0050 end
0051 
0052 % compute mean resultant vector length
0053 r = circ_r(alpha,w,d,dim);
0054 
0055 % apply transformation to var
0056 S = 1 - r;
0057 s = 2 * S;

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