Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
adehad committed May 21, 2019
2 parents 6e62bc3 + 2a94a11 commit c16dcc4
Show file tree
Hide file tree
Showing 38 changed files with 134 additions and 127 deletions.
1 change: 0 additions & 1 deletion Contents.m
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,3 @@
%
% Author:
% Philipp Berens & Marc J. Velasco, 2009

3 changes: 2 additions & 1 deletion circ_ang2rad.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
% By Philipp Berens, 2009
% [email protected] - www.kyb.mpg.de/~berens/circStat.html

alpha = alpha * pi /180;
alpha = alpha * pi /180;
end
1 change: 1 addition & 0 deletions circ_axial.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@
end

alpha = mod(alpha*p,2*pi);
end
11 changes: 7 additions & 4 deletions circ_axialmean.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function [r mu] = circ_axialmean(alphas, m, dim)
function [r, mu] = circ_axialmean(alphas, m, dim)
%
% mu = circ_axialmean(alpha, w)
% Computes the mean direction for circular data with axial
Expand All @@ -7,7 +7,7 @@
% Input:
% alpha sample of angles in radians
% [m axial correction (2,3,4,...)]
% [dim statistic computed along this dimension, 1]
% [dim statistic computed along this dimension, default: 1st non-singular dimension]
%
% Output:
% r mean resultant length
Expand All @@ -27,7 +27,10 @@
% Distributed under Open Source BSD License

if nargin < 3
dim = 1;
dim = find(size(alphas) > 1, 1, 'first');
if isempty(dim)
dim = 1;
end
end

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

r = abs(zbarm);
mu = angle(zbarm)/m;

end
7 changes: 3 additions & 4 deletions circ_clust.m
Original file line number Diff line number Diff line change
Expand Up @@ -138,14 +138,13 @@ function plotColor(x, y, c, varargin)
colors={'y', 'b', 'r', 'g', 'c', 'k', 'm'};

hold on;
for j=1:length(csmall);
for j=1:length(csmall)

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

end
if ~overlay, hold off; end
figure(figurenum)



end
end
6 changes: 3 additions & 3 deletions circ_cmtest.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function [pval med P] = circ_cmtest(varargin)
function [pval, med, P] = circ_cmtest(varargin)
%
% [pval, med, P] = circ_cmtest(alpha, idx)
% [pval, med, P] = circ_cmtest(alpha1, alpha2)
Expand Down Expand Up @@ -68,7 +68,7 @@
if pval < 0.05
med = NaN;
end

end



Expand All @@ -88,4 +88,4 @@
else
error('Invalid use of circ_wwtest. Type help circ_wwtest.')
end

end
12 changes: 6 additions & 6 deletions circ_confmean.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
% [d spacing of bin centers for binned data, if supplied
% correction factor is used to correct for bias in
% estimation of r, in radians (!)]
% [dim compute along this dimension, default is 1]
% [dim compute along this dimension, default: 1st non-singular dimension]
%
% Output:
% t mean +- d yields upper/lower (1-xi)% confidence limit
Expand All @@ -28,7 +28,10 @@
% [email protected] - www.kyb.mpg.de/~berens/circStat.html

if nargin < 5
dim = 1;
dim = find(size(alpha) > 1, 1, 'first');
if isempty(dim)
dim = 1;
end
end

if nargin < 4 || isempty(d)
Expand Down Expand Up @@ -74,7 +77,4 @@

% apply final transform
t = acos(t./R);




end
4 changes: 2 additions & 2 deletions circ_corrcc.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function [rho pval] = circ_corrcc(alpha1, alpha2)
function [rho, pval] = circ_corrcc(alpha1, alpha2)
%
% [rho pval] = circ_corrcc(alpha1, alpha2)
% Circular correlation coefficient for two circular random variables.
Expand Down Expand Up @@ -50,4 +50,4 @@

ts = sqrt((n * l20 * l02)/l22) * rho;
pval = 2 * (1 - normcdf(abs(ts)));

end
4 changes: 2 additions & 2 deletions circ_corrcl.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function [rho pval] = circ_corrcl(alpha, x)
function [rho, pval] = circ_corrcl(alpha, x)
%
% [rho pval] = circ_corrcc(alpha, x)
% Correlation coefficient between one circular and one linear random
Expand Down Expand Up @@ -47,4 +47,4 @@

% compute pvalue
pval = 1 - chi2cdf(n*rho^2,2);

end
3 changes: 2 additions & 1 deletion circ_dist.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@
error('Input dimensions do not match.')
end

r = angle(exp(1i*x)./exp(1i*y));
r = angle(exp(1i*x)./exp(1i*y));
end
3 changes: 2 additions & 1 deletion circ_dist2.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@
end

r = angle(repmat(exp(1i*x),1,length(y)) ...
./ repmat(exp(1i*y'),length(x),1));
./ repmat(exp(1i*y'),length(x),1));
end
14 changes: 1 addition & 13 deletions circ_hktest.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function [pval table] = circ_hktest(alpha, idp, idq, inter, fn)
function [pval, table] = circ_hktest(alpha, idp, idq, inter, fn)

%
% [pval, stats] = circ_hktest(alpha, idp, idq, inter, fn)
Expand Down Expand Up @@ -238,16 +238,4 @@
end

end


end










1 change: 1 addition & 0 deletions circ_kappa.m
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,4 @@
kappa = (N-1)^3*kappa/(N^3+N);
end
end
end
8 changes: 1 addition & 7 deletions circ_ktest.m
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,4 @@
f = 1/f;
pval = 2*(1-fcdf(f, n2, n1));
end







end
13 changes: 6 additions & 7 deletions circ_kuipertest.m
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
m = length(alpha2(:));

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

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

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


Expand All @@ -83,14 +83,14 @@

end

function [p K] = kuiperlookup(n, k)
function [p, K] = kuiperlookup(n, k)

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

% find correct row of the table
[easy row] = ismember(n, nn);
[easy, row] = ismember(n, nn);
if ~easy
% find closest value if no entry is present)
row = length(nn) - sum(n<nn);
Expand All @@ -110,5 +110,4 @@
p = 1;
end
K = ktable(row,idx+1);

end
end
10 changes: 7 additions & 3 deletions circ_kurtosis.m
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
function [k k0] = circ_kurtosis(alpha, w, dim)
function [k, k0] = circ_kurtosis(alpha, w, dim)

% [k k0] = circ_kurtosis(alpha,w,dim)
% Calculates a measure of angular kurtosis.
%
% Input:
% alpha sample of angles
% [w weightings in case of binned angle data]
% [dim statistic computed along this dimension, 1]
% [dim statistic computed along this dimension, default: 1st non-singular dimension]
%
% If dim argument is specified, all other optional arguments can be
% left empty: circ_kurtosis(alpha, [], dim)
Expand All @@ -25,7 +25,10 @@
% [email protected]

if nargin < 3
dim = 1;
dim = find(size(alpha) > 1, 1, 'first');
if isempty(dim)
dim = 1;
end
end

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

12 changes: 8 additions & 4 deletions circ_mean.m
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
function [mu ul ll] = circ_mean(alpha, w, dim)
function [mu, ul, ll] = circ_mean(alpha, w, dim)
%
% [mu ul ll] = circ_mean(alpha, w, dim)
% Computes the mean direction for circular data.
%
% Input:
% alpha sample of angles in radians
% [w weightings in case of binned angle data]
% [dim compute along this dimension, default is 1]
% [dim compute along this dimension, default: 1st non-singular dimension]
%
% If dim argument is specified, all other optional arguments can be
% left empty: circ_mean(alpha, [], dim)
Expand All @@ -29,7 +29,10 @@
% [email protected] - www.kyb.mpg.de/~berens/circStat.html

if nargin < 3
dim = 1;
dim = find(size(alpha) > 1, 1, 'first');
if isempty(dim)
dim = 1;
end
end

if nargin < 2 || isempty(w)
Expand All @@ -53,4 +56,5 @@
t = circ_confmean(alpha,0.05,w,[],dim);
ul = mu + t;
ll = mu - t;
end
end
end
12 changes: 8 additions & 4 deletions circ_median.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
%
% Input:
% alpha sample of angles in radians
% [dim compute along this dimension, default is 1, must
% [dim compute along this dimension, default: 1st non-singular dimension, must
% be either 1 or 2 for circ_median]
%
% Output:
Expand All @@ -25,7 +25,10 @@
% [email protected] - www.kyb.mpg.de/~berens/circStat.html

if nargin < 2
dim = 1;
dim = find(size(alpha) > 1, 1, 'first');
if isempty(dim)
dim = 1;
end
end

M = size(alpha);
Expand All @@ -48,7 +51,7 @@

dm = abs(m1-m2);
if mod(n,2)==1
[m idx] = min(dm);
[m, idx] = min(dm);
else
m = min(dm);
idx = find(dm==m,2);
Expand All @@ -70,4 +73,5 @@

if dim == 2
med = med';
end
end
end
5 changes: 1 addition & 4 deletions circ_medtest.m
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,4 @@

% compute p-value with binomial test
pval = sum(binopdf([0:min(n1,n2) max(n1,n2):n],n,0.5));




end
12 changes: 7 additions & 5 deletions circ_moment.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function [mp rho_p mu_p] = circ_moment(alpha, w, p, cent, dim)
function [mp, rho_p, mu_p] = circ_moment(alpha, w, p, cent, dim)

% [mp rho_p mu_p] = circ_moment(alpha, w, p, cent, dim)
% Calculates the complex p-th centred or non-centred moment
Expand All @@ -9,7 +9,7 @@
% [w weightings in case of binned angle data]
% [p p-th moment to be computed, default is p=1]
% [cent if true, central moments are computed, default = false]
% [dim compute along this dimension, default is 1]
% [dim compute along this dimension, default is 1st non-singular dimension]
%
% If dim argument is specified, all other optional arguments can be
% left empty: circ_moment(alpha, [], [], [], dim)
Expand All @@ -29,7 +29,10 @@
% [email protected]

if nargin < 5
dim = 1;
dim = find(size(alpha) > 1, 1, 'first');
if isempty(dim)
dim = 1;
end
end

if nargin < 4
Expand Down Expand Up @@ -65,5 +68,4 @@

rho_p = abs(mp);
mu_p = angle(mp);


end
Loading

0 comments on commit c16dcc4

Please sign in to comment.