-
Notifications
You must be signed in to change notification settings - Fork 41
/
circ_axialmean.m
44 lines (39 loc) · 1012 Bytes
/
circ_axialmean.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
function [r, mu] = circ_axialmean(alphas, m, dim)
%
% mu = circ_axialmean(alpha, w)
% Computes the mean direction for circular data with axial
% correction.
%
% Input:
% alpha sample of angles in radians
% [m axial correction (2,3,4,...)]
% [dim statistic computed along this dimension, default: 1st non-singular dimension]
%
% Output:
% r mean resultant length
% mu mean direction
%
% 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
% By Philipp Berens, 2009
% [email protected] - www.kyb.mpg.de/~berens/circStat.html
% Distributed under Open Source BSD License
if nargin < 3
dim = find(size(alphas) > 1, 1, 'first');
if isempty(dim)
dim = 1;
end
end
if nargin < 2 || isempty(m)
m = 1;
end
zbarm = mean(exp(1i*alphas*m),dim);
r = abs(zbarm);
mu = angle(zbarm)/m;
end