Skip to content

Commit c16dcc4

Browse files
committed
2 parents 6e62bc3 + 2a94a11 commit c16dcc4

38 files changed

+134
-127
lines changed

Diff for: 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-

Diff for: circ_ang2rad.m

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

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

Diff for: 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

Diff for: 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

Diff for: 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

Diff for: 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

Diff for: 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
% [email protected] - 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

Diff for: 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

Diff for: 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

Diff for: 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

Diff for: 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

Diff for: 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-

Diff for: 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

Diff for: 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

Diff for: 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

Diff for: 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
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

Diff for: 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
% [email protected] - 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

Diff for: 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
% [email protected] - 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

Diff for: 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

Diff for: 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
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

0 commit comments

Comments
 (0)