Skip to content

Commit 8a0a067

Browse files
committedJun 16, 2017
Formatting tweaks
Reformatted to remove MLint warnings - added commas for multiple output arguments, - removed redundant semicolons Files end with one blank line and non-nested functions have "ends"
1 parent 047f607 commit 8a0a067

38 files changed

+79
-133
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

+2-2
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
@@ -38,4 +38,4 @@
3838

3939
r = abs(zbarm);
4040
mu = angle(zbarm)/m;
41-
41+
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)
@@ -67,7 +67,7 @@
6767
if pval < 0.05
6868
med = NaN;
6969
end
70-
70+
end
7171

7272

7373

@@ -87,4 +87,4 @@
8787
else
8888
error('Invalid use of circ_wwtest. Type help circ_wwtest.')
8989
end
90-
90+
end

‎circ_confmean.m

+1-4
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,4 @@
7373

7474
% apply final transform
7575
t = acos(t./R);
76-
77-
78-
79-
76+
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 ts] = 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 ts] = 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
@@ -50,10 +50,4 @@
5050
f = 1/f;
5151
pval = 2*(1-fcdf(f, n2, n1));
5252
end
53-
54-
55-
56-
57-
58-
59-
53+
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);
@@ -109,5 +109,4 @@
109109
p = 1;
110110
end
111111
K = ktable(row,idx+1);
112-
113-
end
112+
end

‎circ_kurtosis.m

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
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.
@@ -48,4 +48,5 @@
4848
theta2 = repmat(theta, size(alpha)./size(theta));
4949
k = sum(w.*(cos(2*(circ_dist(alpha,theta2)))),dim)./sum(w,dim);
5050
k0 = (rho2.*cos(circ_dist(mu2,2*theta))-R.^4)./(1-R).^2; % (formula 2.30)
51+
end
5152

‎circ_mean.m

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function [mu ul ll] = circ_mean(alpha, w, dim)
1+
function [mu, ul, ll] = circ_mean(alpha, w, dim)
22
%
33
% mu = circ_mean(alpha, w)
44
% Computes the mean direction for circular data.
@@ -53,4 +53,5 @@
5353
t = circ_confmean(alpha,0.05,w,[],dim);
5454
ul = mu + t;
5555
ll = mu - t;
56-
end
56+
end
57+
end

‎circ_median.m

+3-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848

4949
dm = abs(m1-m2);
5050
if mod(n,2)==1
51-
[m idx] = min(dm);
51+
[m, idx] = min(dm);
5252
else
5353
m = min(dm);
5454
idx = find(dm==m,2);
@@ -69,4 +69,5 @@
6969

7070
if dim == 2
7171
med = med';
72-
end
72+
end
73+
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

+2-3
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 cbar sbar] = circ_moment(alpha, w, p, cent, dim)
44
% Calculates the complex p-th centred or non-centred moment
@@ -65,5 +65,4 @@
6565

6666
rho_p = abs(mp);
6767
mu_p = angle(mp);
68-
69-
68+
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
% [pval, z] = circ_mtest(alpha, dir, 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

+2-13
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.
@@ -67,15 +67,4 @@
6767
% exact formula by Hodges (1955)
6868
pval = 2^(1-n) * (n-2*m) * nchoosek(n,m);
6969
end
70-
71-
72-
73-
74-
75-
76-
77-
78-
79-
80-
81-
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

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,4 @@
5959
c = d/2/sin(d/2);
6060
r = c*r;
6161
end
62-
62+
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)
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

+2-6
Original file line numberDiff line numberDiff line change
@@ -60,15 +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];
6969
cdfplot = [cdfplottable 1];
70-
71-
72-
73-
74-
70+
end

‎circ_skewness.m

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
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.
@@ -42,11 +42,10 @@
4242
% compute neccessary values
4343
R = circ_r(alpha,w,[],dim);
4444
theta = circ_mean(alpha,w,dim);
45-
[~, rho2 mu2] = circ_moment(alpha,w,2,true,dim);
45+
[~, rho2, mu2] = circ_moment(alpha,w,2,true,dim);
4646

4747
% compute skewness
4848
theta2 = repmat(theta, size(alpha)./size(theta));
4949
b = sum(w.*(sin(2*(circ_dist(alpha,theta2)))),dim)./sum(w,dim);
5050
b0 = rho2.*sin(circ_dist(mu2,2*theta))./(1-R).^(3/2); % (formula 2.29)
51-
52-
51+
end

‎circ_stats.m

+4-7
Original file line numberDiff line numberDiff line change
@@ -52,15 +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);
63-
64-
65-
66-
62+
[stats.kurtosis, stats.kurtosis0] = circ_kurtosis(alpha,w);
63+
end

‎circ_std.m

+2-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 = circ_std(alpha, w, d, dim)
33
% Computes circular standard deviation for circular data
44
% (equ. 26.20, Zar).
@@ -52,6 +52,4 @@
5252

5353
s = sqrt(2*(1-r)); % 26.20
5454
s0 = sqrt(-2*log(r)); % 26.21
55-
56-
57-
55+
end

‎circ_symtest.m

+1-4
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,4 @@
3434

3535
% compute wilcoxon sign rank test
3636
pval = signrank(d);
37-
38-
39-
40-
37+
end

‎circ_var.m

+3-2
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 = circ_var(alpha, w, d, dim)
33
% Computes circular variance for circular data
44
% (equ. 26.17/18, Zar).
@@ -54,4 +54,5 @@
5454

5555
% apply transformation to var
5656
S = 1 - r;
57-
s = 2 * S;
57+
s = 2 * S;
58+
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
% r = 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, w, p)
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

+1-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
% [pval, table] = circ_wwtest(alpha, idx, [w])
33
% [pval, table] = circ_wwtest(alpha1, alpha2, [w1, w2])
44
% Parametric Watson-Williams multi-sample test for equal means. Can be
@@ -155,4 +155,3 @@ function checkAssumption(rw,n)
155155
error('Invalid use of circ_wwtest. Type help circ_wwtest.')
156156
end
157157
end
158-

0 commit comments

Comments
 (0)
Please sign in to comment.