-
Notifications
You must be signed in to change notification settings - Fork 41
/
circ_mtest.m
70 lines (63 loc) · 1.71 KB
/
circ_mtest.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
function [h, mu, ul, ll] = circ_mtest(alpha, dir, xi, w, d)
%
% [h mu ul ll] = circ_mtest(alpha, dir, xi, w, d)
% One-Sample test for the mean angle.
% H0: the population has mean dir.
% HA: the population has not mean dir.
%
% Note: This is the equvivalent to a one-sample t-test with specified
% mean direction.
%
% Input:
% alpha sample of angles in radians
% dir assumed mean direction
% [xi alpha level of the test]
% [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 (!)]
%
% Output:
% h 0 if H0 can not be rejected, 1 otherwise
% mu mean
% ul upper (1-xi) confidence level
% ll lower (1-xi) confidence level
%
% PHB 7/6/2008
%
% References:
% Biostatistical Analysis, J. H. Zar
%
% Circular Statistics Toolbox for Matlab
% By Philipp Berens, 2009
% berens@tuebingen.mpg.de - www.kyb.mpg.de/~berens/circStat.html
if size(alpha,2) > size(alpha,1)
alpha = alpha';
end
if nargin<3
xi = 0.05;
end
if nargin<4
% if no specific weighting has been specified
% assume no binning has taken place
w = ones(size(alpha));
else
if size(w,2) > size(w,1)
w = w';
end
if length(alpha)~=length(w)
error('Input dimensions do not match.')
end
end
if nargin<5
% per default do not apply correct for binned data
d = 0;
end
% compute ingredients
mu = circ_mean(alpha,w);
t = circ_confmean(alpha,xi,w,d);
ul = mu + t;
ll = mu - t;
% compute test via confidence limits (example 27.3)
h = abs(circ_dist2(dir,mu)) > t;
end