Skip to content

Commit c16dcc4

Browse files
committedMay 21, 2019
2 parents 6e62bc3 + 2a94a11 commit c16dcc4

38 files changed

+134
-127
lines changed
 

‎Contents.m

-1
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,3 @@
6060
%
6161
% Author:
6262
% Philipp Berens & Marc J. Velasco, 2009
63-

‎circ_ang2rad.m

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@
88
% By Philipp Berens, 2009
99
% berens@tuebingen.mpg.de - www.kyb.mpg.de/~berens/circStat.html
1010

11-
alpha = alpha * pi /180;
11+
alpha = alpha * pi /180;
12+
end

‎circ_axial.m

+1
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,4 @@
2727
end
2828

2929
alpha = mod(alpha*p,2*pi);
30+
end

‎circ_axialmean.m

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function [r mu] = circ_axialmean(alphas, m, dim)
1+
function [r, mu] = circ_axialmean(alphas, m, dim)
22
%
33
% mu = circ_axialmean(alpha, w)
44
% Computes the mean direction for circular data with axial
@@ -7,7 +7,7 @@
77
% Input:
88
% alpha sample of angles in radians
99
% [m axial correction (2,3,4,...)]
10-
% [dim statistic computed along this dimension, 1]
10+
% [dim statistic computed along this dimension, default: 1st non-singular dimension]
1111
%
1212
% Output:
1313
% r mean resultant length
@@ -27,7 +27,10 @@
2727
% Distributed under Open Source BSD License
2828

2929
if nargin < 3
30-
dim = 1;
30+
dim = find(size(alphas) > 1, 1, 'first');
31+
if isempty(dim)
32+
dim = 1;
33+
end
3134
end
3235

3336
if nargin < 2 || isempty(m)
@@ -38,4 +41,4 @@
3841

3942
r = abs(zbarm);
4043
mu = angle(zbarm)/m;
41-
44+
end

‎circ_clust.m

+3-4
Original file line numberDiff line numberDiff line change
@@ -138,14 +138,13 @@ function plotColor(x, y, c, varargin)
138138
colors={'y', 'b', 'r', 'g', 'c', 'k', 'm'};
139139

140140
hold on;
141-
for j=1:length(csmall);
141+
for j=1:length(csmall)
142142

143143
ci = (c == csmall(j));
144144
plot(x(ci), y(ci), strcat(pstring, colors{mod(j, length(colors))+1}), 'MarkerSize', ms);
145145

146146
end
147147
if ~overlay, hold off; end
148148
figure(figurenum)
149-
150-
151-
149+
end
150+
end

‎circ_cmtest.m

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function [pval med P] = circ_cmtest(varargin)
1+
function [pval, med, P] = circ_cmtest(varargin)
22
%
33
% [pval, med, P] = circ_cmtest(alpha, idx)
44
% [pval, med, P] = circ_cmtest(alpha1, alpha2)
@@ -68,7 +68,7 @@
6868
if pval < 0.05
6969
med = NaN;
7070
end
71-
71+
end
7272

7373

7474

@@ -88,4 +88,4 @@
8888
else
8989
error('Invalid use of circ_wwtest. Type help circ_wwtest.')
9090
end
91-
91+
end

‎circ_confmean.m

+6-6
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
% [d spacing of bin centers for binned data, if supplied
1111
% correction factor is used to correct for bias in
1212
% estimation of r, in radians (!)]
13-
% [dim compute along this dimension, default is 1]
13+
% [dim compute along this dimension, default: 1st non-singular dimension]
1414
%
1515
% Output:
1616
% t mean +- d yields upper/lower (1-xi)% confidence limit
@@ -28,7 +28,10 @@
2828
% berens@tuebingen.mpg.de - www.kyb.mpg.de/~berens/circStat.html
2929

3030
if nargin < 5
31-
dim = 1;
31+
dim = find(size(alpha) > 1, 1, 'first');
32+
if isempty(dim)
33+
dim = 1;
34+
end
3235
end
3336

3437
if nargin < 4 || isempty(d)
@@ -74,7 +77,4 @@
7477

7578
% apply final transform
7679
t = acos(t./R);
77-
78-
79-
80-
80+
end

‎circ_corrcc.m

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function [rho pval] = circ_corrcc(alpha1, alpha2)
1+
function [rho, pval] = circ_corrcc(alpha1, alpha2)
22
%
33
% [rho pval] = circ_corrcc(alpha1, alpha2)
44
% Circular correlation coefficient for two circular random variables.
@@ -50,4 +50,4 @@
5050

5151
ts = sqrt((n * l20 * l02)/l22) * rho;
5252
pval = 2 * (1 - normcdf(abs(ts)));
53-
53+
end

‎circ_corrcl.m

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function [rho pval] = circ_corrcl(alpha, x)
1+
function [rho, pval] = circ_corrcl(alpha, x)
22
%
33
% [rho pval] = circ_corrcc(alpha, x)
44
% Correlation coefficient between one circular and one linear random
@@ -47,4 +47,4 @@
4747

4848
% compute pvalue
4949
pval = 1 - chi2cdf(n*rho^2,2);
50-
50+
end

‎circ_dist.m

+2-1
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,5 @@
2525
error('Input dimensions do not match.')
2626
end
2727

28-
r = angle(exp(1i*x)./exp(1i*y));
28+
r = angle(exp(1i*x)./exp(1i*y));
29+
end

‎circ_dist2.m

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,5 @@
3333
end
3434

3535
r = angle(repmat(exp(1i*x),1,length(y)) ...
36-
./ repmat(exp(1i*y'),length(x),1));
36+
./ repmat(exp(1i*y'),length(x),1));
37+
end

‎circ_hktest.m

+1-13
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function [pval table] = circ_hktest(alpha, idp, idq, inter, fn)
1+
function [pval, table] = circ_hktest(alpha, idp, idq, inter, fn)
22

33
%
44
% [pval, stats] = circ_hktest(alpha, idp, idq, inter, fn)
@@ -238,16 +238,4 @@
238238
end
239239

240240
end
241-
242-
243241
end
244-
245-
246-
247-
248-
249-
250-
251-
252-
253-

‎circ_kappa.m

+1
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,4 @@
5555
kappa = (N-1)^3*kappa/(N^3+N);
5656
end
5757
end
58+
end

‎circ_ktest.m

+1-7
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,4 @@
5151
f = 1/f;
5252
pval = 2*(1-fcdf(f, n2, n1));
5353
end
54-
55-
56-
57-
58-
59-
60-
54+
end

‎circ_kuipertest.m

+6-7
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@
4545
m = length(alpha2(:));
4646

4747
% create cdfs of both samples
48-
[phis1 cdf1 phiplot1 cdfplot1] = circ_samplecdf(alpha1, res);
49-
[foo, cdf2 phiplot2 cdfplot2] = circ_samplecdf(alpha2, res); %#ok<ASGLU>
48+
[phis1, cdf1, phiplot1, cdfplot1] = circ_samplecdf(alpha1, res);
49+
[foo, cdf2, phiplot2, cdfplot2] = circ_samplecdf(alpha2, res); %#ok<ASGLU>
5050

5151
% maximal difference between sample cdfs
5252
[dplus, gdpi] = max([0 cdf1-cdf2]);
@@ -56,7 +56,7 @@
5656
k = n * m * (dplus + dminus);
5757

5858
% find p-value
59-
[pval K] = kuiperlookup(min(n,m),k/sqrt(n*m*(n+m)));
59+
[pval, K] = kuiperlookup(min(n,m),k/sqrt(n*m*(n+m)));
6060
K = K * sqrt(n*m*(n+m));
6161

6262

@@ -83,14 +83,14 @@
8383

8484
end
8585

86-
function [p K] = kuiperlookup(n, k)
86+
function [p, K] = kuiperlookup(n, k)
8787

8888
load kuipertable.mat;
8989
alpha = [.10, .05, .02, .01, .005, .002, .001];
9090
nn = ktable(:,1); %#ok<NODEF>
9191

9292
% find correct row of the table
93-
[easy row] = ismember(n, nn);
93+
[easy, row] = ismember(n, nn);
9494
if ~easy
9595
% find closest value if no entry is present)
9696
row = length(nn) - sum(n<nn);
@@ -110,5 +110,4 @@
110110
p = 1;
111111
end
112112
K = ktable(row,idx+1);
113-
114-
end
113+
end

‎circ_kurtosis.m

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
function [k k0] = circ_kurtosis(alpha, w, dim)
1+
function [k, k0] = circ_kurtosis(alpha, w, dim)
22

33
% [k k0] = circ_kurtosis(alpha,w,dim)
44
% Calculates a measure of angular kurtosis.
55
%
66
% Input:
77
% alpha sample of angles
88
% [w weightings in case of binned angle data]
9-
% [dim statistic computed along this dimension, 1]
9+
% [dim statistic computed along this dimension, default: 1st non-singular dimension]
1010
%
1111
% If dim argument is specified, all other optional arguments can be
1212
% left empty: circ_kurtosis(alpha, [], dim)
@@ -25,7 +25,10 @@
2525
% berens@tuebingen.mpg.de
2626

2727
if nargin < 3
28-
dim = 1;
28+
dim = find(size(alpha) > 1, 1, 'first');
29+
if isempty(dim)
30+
dim = 1;
31+
end
2932
end
3033

3134
if nargin < 2 || isempty(w)
@@ -48,4 +51,5 @@
4851
theta2 = repmat(theta, size(alpha)./size(theta));
4952
k = sum(w.*(cos(2*(circ_dist(alpha,theta2)))),dim)./sum(w,dim);
5053
k0 = (rho2.*cos(circ_dist(mu2,2*theta))-R.^4)./(1-R).^2; % (formula 2.30)
54+
end
5155

‎circ_mean.m

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
function [mu ul ll] = circ_mean(alpha, w, dim)
1+
function [mu, ul, ll] = circ_mean(alpha, w, dim)
22
%
33
% [mu ul ll] = circ_mean(alpha, w, dim)
44
% Computes the mean direction for circular data.
55
%
66
% Input:
77
% alpha sample of angles in radians
88
% [w weightings in case of binned angle data]
9-
% [dim compute along this dimension, default is 1]
9+
% [dim compute along this dimension, default: 1st non-singular dimension]
1010
%
1111
% If dim argument is specified, all other optional arguments can be
1212
% left empty: circ_mean(alpha, [], dim)
@@ -29,7 +29,10 @@
2929
% berens@tuebingen.mpg.de - www.kyb.mpg.de/~berens/circStat.html
3030

3131
if nargin < 3
32-
dim = 1;
32+
dim = find(size(alpha) > 1, 1, 'first');
33+
if isempty(dim)
34+
dim = 1;
35+
end
3336
end
3437

3538
if nargin < 2 || isempty(w)
@@ -53,4 +56,5 @@
5356
t = circ_confmean(alpha,0.05,w,[],dim);
5457
ul = mu + t;
5558
ll = mu - t;
56-
end
59+
end
60+
end

‎circ_median.m

+8-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
%
66
% Input:
77
% alpha sample of angles in radians
8-
% [dim compute along this dimension, default is 1, must
8+
% [dim compute along this dimension, default: 1st non-singular dimension, must
99
% be either 1 or 2 for circ_median]
1010
%
1111
% Output:
@@ -25,7 +25,10 @@
2525
% berens@tuebingen.mpg.de - www.kyb.mpg.de/~berens/circStat.html
2626

2727
if nargin < 2
28-
dim = 1;
28+
dim = find(size(alpha) > 1, 1, 'first');
29+
if isempty(dim)
30+
dim = 1;
31+
end
2932
end
3033

3134
M = size(alpha);
@@ -48,7 +51,7 @@
4851

4952
dm = abs(m1-m2);
5053
if mod(n,2)==1
51-
[m idx] = min(dm);
54+
[m, idx] = min(dm);
5255
else
5356
m = min(dm);
5457
idx = find(dm==m,2);
@@ -70,4 +73,5 @@
7073

7174
if dim == 2
7275
med = med';
73-
end
76+
end
77+
end

‎circ_medtest.m

+1-4
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,4 @@
4040

4141
% compute p-value with binomial test
4242
pval = sum(binopdf([0:min(n1,n2) max(n1,n2):n],n,0.5));
43-
44-
45-
46-
43+
end

‎circ_moment.m

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function [mp rho_p mu_p] = circ_moment(alpha, w, p, cent, dim)
1+
function [mp, rho_p, mu_p] = circ_moment(alpha, w, p, cent, dim)
22

33
% [mp rho_p mu_p] = circ_moment(alpha, w, p, cent, dim)
44
% Calculates the complex p-th centred or non-centred moment
@@ -9,7 +9,7 @@
99
% [w weightings in case of binned angle data]
1010
% [p p-th moment to be computed, default is p=1]
1111
% [cent if true, central moments are computed, default = false]
12-
% [dim compute along this dimension, default is 1]
12+
% [dim compute along this dimension, default is 1st non-singular dimension]
1313
%
1414
% If dim argument is specified, all other optional arguments can be
1515
% left empty: circ_moment(alpha, [], [], [], dim)
@@ -29,7 +29,10 @@
2929
% berens@tuebingen.mpg.de
3030

3131
if nargin < 5
32-
dim = 1;
32+
dim = find(size(alpha) > 1, 1, 'first');
33+
if isempty(dim)
34+
dim = 1;
35+
end
3336
end
3437

3538
if nargin < 4
@@ -65,5 +68,4 @@
6568

6669
rho_p = abs(mp);
6770
mu_p = angle(mp);
68-
69-
71+
end

‎circ_mtest.m

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function [h mu ul ll] = circ_mtest(alpha, dir, xi, w, d)
1+
function [h, mu, ul, ll] = circ_mtest(alpha, dir, xi, w, d)
22
%
33
% [h mu ul ll] = circ_mtest(alpha, dir, xi, w, d)
44
% One-Sample test for the mean angle.
@@ -67,3 +67,4 @@
6767

6868
% compute test via confidence limits (example 27.3)
6969
h = abs(circ_dist2(dir,mu)) > t;
70+
end

‎circ_otest.m

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function [pval m] = circ_otest(alpha, sz, w)
1+
function [pval, m] = circ_otest(alpha, sz, w)
22
%
33
% [pval, m] = circ_otest(alpha,sz,w)
44
% Computes Omnibus or Hodges-Ajne test for non-uniformity of circular data.
@@ -66,4 +66,5 @@
6666
else
6767
% exact formula by Hodges (1955)
6868
pval = 2^(1-n) * (n-2*m) * nchoosek(n,m);
69-
end
69+
end
70+
end

‎circ_plot.m

+2-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
set(gca,'box','off')
9090
set(gca,'xtick',[])
9191
set(gca,'ytick',[])
92-
text(1.2, 0, '0'); text(-.05, 1.2, '\pi/2'); text(-1.35, 0, '±\pi'); text(-.075, -1.2, '-\pi/2');
92+
text(1.2, 0, '0'); text(-.05, 1.2, '\pi/2'); text(-1.35, 0, '\pi'); text(-.075, -1.2, '-\pi/2');
9393

9494

9595
case 'hist'
@@ -141,3 +141,4 @@
141141
end
142142

143143
a = gca;
144+
end

‎circ_r.m

+6-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
% [d spacing of bin centers for binned data, if supplied
99
% correction factor is used to correct for bias in
1010
% estimation of r, in radians (!)]
11-
% [dim compute along this dimension, default is 1]
11+
% [dim compute along this dimension, default: 1st non-singular dimension]
1212
%
1313
% If dim argument is specified, all other optional arguments can be
1414
% left empty: circ_r(alpha, [], [], dim)
@@ -29,7 +29,10 @@
2929
% berens@tuebingen.mpg.de - www.kyb.mpg.de/~berens/circStat.html
3030

3131
if nargin < 4
32-
dim = 1;
32+
dim = find(size(alpha) > 1, 1, 'first');
33+
if isempty(dim)
34+
dim = 1;
35+
end
3336
end
3437

3538
if nargin < 2 || isempty(w)
@@ -59,4 +62,4 @@
5962
c = d/2/sin(d/2);
6063
r = c*r;
6164
end
62-
65+
end

‎circ_rad2ang.m

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@
88
% By Philipp Berens, 2009
99
% berens@tuebingen.mpg.de - www.kyb.mpg.de/~berens/circStat.html
1010

11-
alpha = alpha / pi *180;
11+
alpha = alpha / pi *180;
12+
end

‎circ_raotest.m

+5-9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function [p U UC] = circ_raotest(alpha)
1+
function [p, U, UC] = circ_raotest(alpha)
22
%
33
% [p U UC] = circ_raotest(alpha)
44
% Calculates Rao's spacing test by comparing distances between points on
@@ -59,11 +59,11 @@
5959
U = (1/2)*U;
6060

6161
% get critical value from table
62-
[p UC] = getVal(n,U);
62+
[p, UC] = getVal(n,U);
6363

6464

6565

66-
function [p UC] = getVal(N, U)
66+
function [p, UC] = getVal(N, U)
6767

6868
% Table II from Russel and Levitin, 1995
6969

@@ -122,9 +122,5 @@
122122
UC = table(ridx,end-1);
123123
p = .5;
124124
end
125-
126-
127-
128-
129-
130-
125+
end
126+
end

‎circ_rtest.m

+2-9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function [pval z] = circ_rtest(alpha, w, d)
1+
function [pval, z] = circ_rtest(alpha, w, d)
22
%
33
% [pval, z] = circ_rtest(alpha,w,d)
44
% Computes Rayleigh test for non-uniformity of circular data.
@@ -65,11 +65,4 @@
6565
% (24*z - 132*z^2 + 76*z^3 - 9*z^4) / (288*n^2));
6666
% end
6767

68-
69-
70-
71-
72-
73-
74-
75-
68+
end

‎circ_samplecdf.m

+3-2
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,11 @@
6060
cdfplottable = [];
6161
phisplottable = [];
6262

63-
for j=1:length(phis);
63+
for j=1:length(phis)
6464
phisplottable = [phisplottable phis(j) phis2(j)]; %#ok<AGROW>
6565
cdfplottable = [cdfplottable cdf2(j) cdf(j)]; %#ok<AGROW>
6666
end
6767

6868
phiplot = [phisplottable 2*pi];
69-
cdfplot = [cdfplottable 1];
69+
cdfplot = [cdfplottable 1];
70+
end

‎circ_skewness.m

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
function [b b0] = circ_skewness(alpha, w, dim)
1+
function [b, b0] = circ_skewness(alpha, w, dim)
22
%
33
% [b b0] = circ_skewness(alpha,w,dim)
44
% Calculates a measure of angular skewness.
55
%
66
% Input:
77
% alpha sample of angles
88
% [w weightings in case of binned angle data]
9-
% [dim statistic computed along this dimension, 1]
9+
% [dim statistic computed along this dimension, default: 1st non-singular dimension]
1010
%
1111
% If dim argument is specified, all other optional arguments can be
1212
% left empty: circ_skewness(alpha, [], dim)
@@ -25,7 +25,10 @@
2525
% berens@tuebingen.mpg.de
2626

2727
if nargin < 3
28-
dim = 1;
28+
dim = find(size(alpha) > 1, 1, 'first');
29+
if isempty(dim)
30+
dim = 1;
31+
end
2932
end
3033

3134
if nargin < 2 || isempty(w)
@@ -47,4 +50,5 @@
4750
% compute skewness
4851
theta2 = repmat(theta, size(alpha)./size(theta));
4952
b = sum(w.*(sin(2*(circ_dist(alpha,theta2)))),dim)./sum(w,dim);
50-
b0 = rho2.*sin(circ_dist(mu2,2*theta))./(1-R).^(3/2); % (formula 2.29)
53+
b0 = rho2.*sin(circ_dist(mu2,2*theta))./(1-R).^(3/2); % (formula 2.29)
54+
end

‎circ_stats.m

+4-3
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,12 @@
5252
stats.var = circ_var(alpha,w,d);
5353

5454
% standard deviation
55-
[stats.std stats.std0] = circ_std(alpha,w,d);
55+
[stats.std, stats.std0] = circ_std(alpha,w,d);
5656

5757

5858
% skewness
59-
[stats.skewness stats.skewness0] = circ_skewness(alpha,w);
59+
[stats.skewness, stats.skewness0] = circ_skewness(alpha,w);
6060

6161
% kurtosis
62-
[stats.kurtosis stats.kurtosis0] = circ_kurtosis(alpha,w);
62+
[stats.kurtosis, stats.kurtosis0] = circ_kurtosis(alpha,w);
63+
end

‎circ_std.m

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function [s s0] = circ_std(alpha, w, d, dim)
1+
function [s, s0] = circ_std(alpha, w, d, dim)
22
% [s, s0] = circ_std(alpha, w, d, dim)
33
% Computes circular standard deviation for circular data
44
% (equ. 26.20, Zar).
@@ -9,7 +9,7 @@
99
% [d spacing of bin centers for binned data, if supplied
1010
% correction factor is used to correct for bias in
1111
% estimation of r]
12-
% [dim compute along this dimension, default is 1]
12+
% [dim compute along this dimension, default: 1st non-singular dimension]
1313
%
1414
% If dim argument is specified, all other optional arguments can be
1515
% left empty: circ_std(alpha, [], [], dim)
@@ -29,7 +29,10 @@
2929
% berens@tuebingen.mpg.de - www.kyb.mpg.de/~berens/circStat.html
3030

3131
if nargin < 4
32-
dim = 1;
32+
dim = find(size(alpha) > 1, 1, 'first');
33+
if isempty(dim)
34+
dim = 1;
35+
end
3336
end
3437

3538
if nargin < 3 || isempty(d)
@@ -51,4 +54,5 @@
5154
r = circ_r(alpha,w,d,dim);
5255

5356
s = sqrt(2*(1-r)); % 26.20
54-
s0 = sqrt(-2*log(r)); % 26.21
57+
s0 = sqrt(-2*log(r)); % 26.21
58+
end

‎circ_symtest.m

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,5 @@
3333
d = circ_dist(alpha,md);
3434

3535
% compute wilcoxon sign rank test
36-
pval = signrank(d);
36+
pval = signrank(d);
37+
end

‎circ_var.m

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function [S s] = circ_var(alpha, w, d, dim)
1+
function [S, s] = circ_var(alpha, w, d, dim)
22
% [S, s] = circ_var(alpha, w, d, dim)
33
% Computes circular variance for circular data
44
% (equ. 26.17/18, Zar).
@@ -9,7 +9,7 @@
99
% [d spacing of bin centers for binned data, if supplied
1010
% correction factor is used to correct for bias in
1111
% estimation of r]
12-
% [dim compute along this dimension, default is 1]
12+
% [dim compute along this dimension, default: 1st non-singular dimension]
1313
%
1414
% If dim argument is specified, all other optional arguments can be
1515
% left empty: circ_var(alpha, [], [], dim)
@@ -31,7 +31,10 @@
3131
% berens@tuebingen.mpg.de - www.kyb.mpg.de/~berens/circStat.html
3232

3333
if nargin < 4
34-
dim = 1;
34+
dim = find(size(alpha) > 1, 1, 'first');
35+
if isempty(dim)
36+
dim = 1;
37+
end
3538
end
3639

3740
if nargin < 3 || isempty(d)
@@ -54,4 +57,5 @@
5457

5558
% apply transformation to var
5659
S = 1 - r;
57-
s = 2 * S;
60+
s = 2 * S;
61+
end

‎circ_vmpar.m

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function [thetahat kappa] = circ_vmpar(alpha,w,d)
1+
function [thetahat, kappa] = circ_vmpar(alpha,w,d)
22
%
33
% [thetahat, kappa] = circ_vmpar(alpha, w, d)
44
% Estimate the parameters of a von Mises distribution.
@@ -36,3 +36,4 @@
3636
kappa = circ_kappa(r);
3737

3838
thetahat = circ_mean(alpha,w);
39+
end

‎circ_vmpdf.m

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function [p alpha] = circ_vmpdf(alpha, thetahat, kappa)
1+
function [p, alpha] = circ_vmpdf(alpha, thetahat, kappa)
22
%
33
% [p alpha] = circ_vmpdf(alpha, thetahat, kappa)
44
% Computes the circular von Mises pdf with preferred direction thetahat
@@ -44,3 +44,4 @@
4444
% evaluate pdf
4545
C = 1/(2*pi*besseli(0,kappa));
4646
p = C * exp(kappa*cos(alpha-thetahat));
47+
end

‎circ_vmrnd.m

+1-6
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,4 @@
7979
if exist('m','var')
8080
alpha = reshape(alpha,m(1),m(2));
8181
end
82-
83-
84-
85-
86-
87-
82+
end

‎circ_vtest.m

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function [pval v] = circ_vtest(alpha, dir, w, d)
1+
function [pval, v] = circ_vtest(alpha, dir, w, d)
22
%
33
% [pval, v] = circ_vtest(alpha, dir, w, d)
44
% Computes V test for non-uniformity of circular data with a specified
@@ -75,3 +75,4 @@
7575

7676
% compute p-value from one tailed normal approximation
7777
pval = 1 - normcdf(u);
78+
end

‎circ_wwtest.m

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function [pval table] = circ_wwtest(varargin)
1+
function [pval, table] = circ_wwtest(varargin)
22
%
33
% [pval, table] = circ_wwtest(alpha, idx, [w])
44
% [pval, table] = circ_wwtest(alpha1, alpha2, [w1, w2])
@@ -159,4 +159,4 @@ function checkAssumption(rw,n)
159159
else
160160
error('Invalid use of circ_wwtest. Type help circ_wwtest.')
161161
end
162-
end
162+
end

0 commit comments

Comments
 (0)
Please sign in to comment.