Home > atmlab > circular > circ_moment.m

circ_moment

PURPOSE ^

[mp cbar sbar] = circ_moment(alpha, w, p, cent, dim)

SYNOPSIS ^

function [mp rho_p mu_p] = circ_moment(alpha, w, p, cent, dim)

DESCRIPTION ^

 [mp cbar sbar] = circ_moment(alpha, w, p, cent, dim)
   Calculates the complex p-th centred or non-centred moment 
   of the angular data in angle.

   Input:
     alpha     sample of angles
     [w        weightings in case of binned angle data]
     [p        p-th moment to be computed, default is p=1]
     [cent     if true, central moments are computed, default = false]
     [dim      compute along this dimension, default is 1]

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

   Output:
     mp        complex p-th moment
     rho_p     magnitude of the p-th moment
     mu_p      angle of th p-th moment


   References:
     Statistical analysis of circular data, Fisher, p. 33/34

 Circular Statistics Toolbox for Matlab

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

circ_moment.m

SOURCE CODE ^

0001 function [mp  rho_p mu_p] = circ_moment(alpha, w, p, cent, dim)
0002 
0003 % [mp cbar sbar] = circ_moment(alpha, w, p, cent, dim)
0004 %   Calculates the complex p-th centred or non-centred moment
0005 %   of the angular data in angle.
0006 %
0007 %   Input:
0008 %     alpha     sample of angles
0009 %     [w        weightings in case of binned angle data]
0010 %     [p        p-th moment to be computed, default is p=1]
0011 %     [cent     if true, central moments are computed, default = false]
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_moment(alpha, [], [], [], dim)
0016 %
0017 %   Output:
0018 %     mp        complex p-th moment
0019 %     rho_p     magnitude of the p-th moment
0020 %     mu_p      angle of th p-th moment
0021 %
0022 %
0023 %   References:
0024 %     Statistical analysis of circular data, Fisher, p. 33/34
0025 %
0026 % Circular Statistics Toolbox for Matlab
0027 
0028 % By Philipp Berens, 2009
0029 % berens@tuebingen.mpg.de
0030 
0031 if nargin < 5
0032   dim = 1;
0033 end
0034 
0035 if nargin < 4
0036   cent = false;
0037 end
0038 
0039 if nargin < 3 || isempty(p)
0040     p = 1;
0041 end
0042 
0043 if nargin < 2 || isempty(w)
0044   % if no specific weighting has been specified
0045   % assume no binning has taken place
0046     w = ones(size(alpha));
0047 else
0048   if size(w,2) ~= size(alpha,2) || size(w,1) ~= size(alpha,1) 
0049     error('Input dimensions do not match');
0050   end 
0051 end
0052 
0053 
0054 if cent
0055   theta = circ_mean(alpha,w,dim);
0056   v = size(alpha)./size(theta);
0057   alpha = circ_dist(alpha,repmat(theta,v));
0058 end
0059   
0060 
0061 n = size(alpha,dim);
0062 cbar = sum(cos(p*alpha).*w,dim)/n;
0063 sbar = sum(sin(p*alpha).*w,dim)/n;
0064 mp = cbar + i*sbar;
0065 
0066 rho_p = abs(mp);
0067 mu_p = angle(mp);
0068 
0069

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