From 8a0a067304970bc7cefdcfc5eedfadd7ec9c37a6 Mon Sep 17 00:00:00 2001 From: Matthew Krause Date: Fri, 16 Jun 2017 16:28:22 -0400 Subject: [PATCH 1/2] 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" --- Contents.m | 1 - circ_ang2rad.m | 3 ++- circ_axial.m | 1 + circ_axialmean.m | 4 ++-- circ_clust.m | 7 +++---- circ_cmtest.m | 6 +++--- circ_confmean.m | 5 +---- circ_corrcc.m | 4 ++-- circ_corrcl.m | 4 ++-- circ_dist.m | 3 ++- circ_dist2.m | 3 ++- circ_hktest.m | 14 +------------- circ_kappa.m | 1 + circ_ktest.m | 8 +------- circ_kuipertest.m | 13 ++++++------- circ_kurtosis.m | 3 ++- circ_mean.m | 5 +++-- circ_median.m | 5 +++-- circ_medtest.m | 5 +---- circ_moment.m | 5 ++--- circ_mtest.m | 3 ++- circ_otest.m | 15 ++------------- circ_plot.m | 3 ++- circ_r.m | 2 +- circ_rad2ang.m | 3 ++- circ_raotest.m | 14 +++++--------- circ_rtest.m | 11 ++--------- circ_samplecdf.m | 8 ++------ circ_skewness.m | 7 +++---- circ_stats.m | 11 ++++------- circ_std.m | 6 ++---- circ_symtest.m | 5 +---- circ_var.m | 5 +++-- circ_vmpar.m | 3 ++- circ_vmpdf.m | 3 ++- circ_vmrnd.m | 7 +------ circ_vtest.m | 3 ++- circ_wwtest.m | 3 +-- 38 files changed, 79 insertions(+), 133 deletions(-) diff --git a/Contents.m b/Contents.m index b08fdef..7bfcb86 100644 --- a/Contents.m +++ b/Contents.m @@ -60,4 +60,3 @@ % % Author: % Philipp Berens & Marc J. Velasco, 2009 - diff --git a/circ_ang2rad.m b/circ_ang2rad.m index 215fcbb..0bb1677 100644 --- a/circ_ang2rad.m +++ b/circ_ang2rad.m @@ -8,4 +8,5 @@ % By Philipp Berens, 2009 % berens@tuebingen.mpg.de - www.kyb.mpg.de/~berens/circStat.html -alpha = alpha * pi /180; \ No newline at end of file +alpha = alpha * pi /180; +end diff --git a/circ_axial.m b/circ_axial.m index c0bb94c..3605c14 100644 --- a/circ_axial.m +++ b/circ_axial.m @@ -27,3 +27,4 @@ end alpha = mod(alpha*p,2*pi); +end diff --git a/circ_axialmean.m b/circ_axialmean.m index ce1f60f..8796e16 100644 --- a/circ_axialmean.m +++ b/circ_axialmean.m @@ -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 @@ -38,4 +38,4 @@ r = abs(zbarm); mu = angle(zbarm)/m; - +end diff --git a/circ_clust.m b/circ_clust.m index 37d58b4..b95450f 100644 --- a/circ_clust.m +++ b/circ_clust.m @@ -138,7 +138,7 @@ 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); @@ -146,6 +146,5 @@ function plotColor(x, y, c, varargin) end if ~overlay, hold off; end figure(figurenum) - - - +end +end diff --git a/circ_cmtest.m b/circ_cmtest.m index c2d4cda..d853232 100644 --- a/circ_cmtest.m +++ b/circ_cmtest.m @@ -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) @@ -67,7 +67,7 @@ if pval < 0.05 med = NaN; end - +end @@ -87,4 +87,4 @@ else error('Invalid use of circ_wwtest. Type help circ_wwtest.') end - +end diff --git a/circ_confmean.m b/circ_confmean.m index 44a9b9b..40cf1cf 100644 --- a/circ_confmean.m +++ b/circ_confmean.m @@ -73,7 +73,4 @@ % apply final transform t = acos(t./R); - - - - +end diff --git a/circ_corrcc.m b/circ_corrcc.m index 2071e65..82ffef7 100644 --- a/circ_corrcc.m +++ b/circ_corrcc.m @@ -1,4 +1,4 @@ -function [rho pval] = circ_corrcc(alpha1, alpha2) +function [rho, pval] = circ_corrcc(alpha1, alpha2) % % [rho pval ts] = circ_corrcc(alpha1, alpha2) % Circular correlation coefficient for two circular random variables. @@ -50,4 +50,4 @@ ts = sqrt((n * l20 * l02)/l22) * rho; pval = 2 * (1 - normcdf(abs(ts))); - +end diff --git a/circ_corrcl.m b/circ_corrcl.m index e4dd7fd..b4fa27e 100644 --- a/circ_corrcl.m +++ b/circ_corrcl.m @@ -1,4 +1,4 @@ -function [rho pval] = circ_corrcl(alpha, x) +function [rho, pval] = circ_corrcl(alpha, x) % % [rho pval ts] = circ_corrcc(alpha, x) % Correlation coefficient between one circular and one linear random @@ -47,4 +47,4 @@ % compute pvalue pval = 1 - chi2cdf(n*rho^2,2); - +end diff --git a/circ_dist.m b/circ_dist.m index 1ba0eaf..b9a90ae 100644 --- a/circ_dist.m +++ b/circ_dist.m @@ -25,4 +25,5 @@ error('Input dimensions do not match.') end -r = angle(exp(1i*x)./exp(1i*y)); \ No newline at end of file +r = angle(exp(1i*x)./exp(1i*y)); +end diff --git a/circ_dist2.m b/circ_dist2.m index d541110..ab48262 100644 --- a/circ_dist2.m +++ b/circ_dist2.m @@ -33,4 +33,5 @@ end r = angle(repmat(exp(1i*x),1,length(y)) ... - ./ repmat(exp(1i*y'),length(x),1)); \ No newline at end of file + ./ repmat(exp(1i*y'),length(x),1)); +end diff --git a/circ_hktest.m b/circ_hktest.m index fe976dc..17c6745 100644 --- a/circ_hktest.m +++ b/circ_hktest.m @@ -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) @@ -238,16 +238,4 @@ end end - - end - - - - - - - - - - diff --git a/circ_kappa.m b/circ_kappa.m index 78d3ffc..76852db 100644 --- a/circ_kappa.m +++ b/circ_kappa.m @@ -55,3 +55,4 @@ kappa = (N-1)^3*kappa/(N^3+N); end end +end diff --git a/circ_ktest.m b/circ_ktest.m index 25ede86..e8c5f81 100644 --- a/circ_ktest.m +++ b/circ_ktest.m @@ -50,10 +50,4 @@ f = 1/f; pval = 2*(1-fcdf(f, n2, n1)); end - - - - - - - +end diff --git a/circ_kuipertest.m b/circ_kuipertest.m index 37e6b1f..afb2259 100644 --- a/circ_kuipertest.m +++ b/circ_kuipertest.m @@ -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 +[phis1, cdf1, phiplot1, cdfplot1] = circ_samplecdf(alpha1, res); +[foo, cdf2, phiplot2, cdfplot2] = circ_samplecdf(alpha2, res); %#ok % maximal difference between sample cdfs [dplus, gdpi] = max([0 cdf1-cdf2]); @@ -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)); @@ -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 % 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 t; +end diff --git a/circ_otest.m b/circ_otest.m index b5db47e..3f255b6 100644 --- a/circ_otest.m +++ b/circ_otest.m @@ -1,4 +1,4 @@ -function [pval m] = circ_otest(alpha, sz, w) +function [pval, m] = circ_otest(alpha, sz, w) % % [pval, m] = circ_otest(alpha,sz,w) % Computes Omnibus or Hodges-Ajne test for non-uniformity of circular data. @@ -67,15 +67,4 @@ % exact formula by Hodges (1955) pval = 2^(1-n) * (n-2*m) * nchoosek(n,m); end - - - - - - - - - - - - +end diff --git a/circ_plot.m b/circ_plot.m index c07a0fe..1b43d61 100644 --- a/circ_plot.m +++ b/circ_plot.m @@ -89,7 +89,7 @@ set(gca,'box','off') set(gca,'xtick',[]) set(gca,'ytick',[]) - text(1.2, 0, '0'); text(-.05, 1.2, '\pi/2'); text(-1.35, 0, '±\pi'); text(-.075, -1.2, '-\pi/2'); + text(1.2, 0, '0'); text(-.05, 1.2, '\pi/2'); text(-1.35, 0, '�\pi'); text(-.075, -1.2, '-\pi/2'); case 'hist' @@ -141,3 +141,4 @@ end a = gca; +end diff --git a/circ_r.m b/circ_r.m index d2768dc..c1c9aea 100644 --- a/circ_r.m +++ b/circ_r.m @@ -59,4 +59,4 @@ c = d/2/sin(d/2); r = c*r; end - +end diff --git a/circ_rad2ang.m b/circ_rad2ang.m index 9a0ae4d..caf3aad 100644 --- a/circ_rad2ang.m +++ b/circ_rad2ang.m @@ -8,4 +8,5 @@ % By Philipp Berens, 2009 % berens@tuebingen.mpg.de - www.kyb.mpg.de/~berens/circStat.html -alpha = alpha / pi *180; \ No newline at end of file +alpha = alpha / pi *180; +end diff --git a/circ_raotest.m b/circ_raotest.m index ec31576..a478cac 100644 --- a/circ_raotest.m +++ b/circ_raotest.m @@ -1,4 +1,4 @@ -function [p U UC] = circ_raotest(alpha) +function [p, U, UC] = circ_raotest(alpha) % [p U UC] = circ_raotest(alpha) % Calculates Rao's spacing test by comparing distances between points on @@ -59,11 +59,11 @@ U = (1/2)*U; % get critical value from table -[p UC] = getVal(n,U); +[p, UC] = getVal(n,U); -function [p UC] = getVal(N, U) +function [p, UC] = getVal(N, U) % Table II from Russel and Levitin, 1995 @@ -122,9 +122,5 @@ UC = table(ridx,end-1); p = .5; end - - - - - - +end +end diff --git a/circ_rtest.m b/circ_rtest.m index eaaafd8..9875933 100644 --- a/circ_rtest.m +++ b/circ_rtest.m @@ -1,4 +1,4 @@ -function [pval z] = circ_rtest(alpha, w, d) +function [pval, z] = circ_rtest(alpha, w, d) % % [pval, z] = circ_rtest(alpha,w) % Computes Rayleigh test for non-uniformity of circular data. @@ -65,11 +65,4 @@ % (24*z - 132*z^2 + 76*z^3 - 9*z^4) / (288*n^2)); % end - - - - - - - - +end diff --git a/circ_samplecdf.m b/circ_samplecdf.m index 39df433..c498c39 100644 --- a/circ_samplecdf.m +++ b/circ_samplecdf.m @@ -60,15 +60,11 @@ cdfplottable = []; phisplottable = []; -for j=1:length(phis); +for j=1:length(phis) phisplottable = [phisplottable phis(j) phis2(j)]; %#ok cdfplottable = [cdfplottable cdf2(j) cdf(j)]; %#ok end phiplot = [phisplottable 2*pi]; cdfplot = [cdfplottable 1]; - - - - - +end diff --git a/circ_skewness.m b/circ_skewness.m index bb21878..6c563f3 100644 --- a/circ_skewness.m +++ b/circ_skewness.m @@ -1,4 +1,4 @@ -function [b b0] = circ_skewness(alpha, w, dim) +function [b, b0] = circ_skewness(alpha, w, dim) % [b b0] = circ_skewness(alpha,w,dim) % Calculates a measure of angular skewness. @@ -42,11 +42,10 @@ % compute neccessary values R = circ_r(alpha,w,[],dim); theta = circ_mean(alpha,w,dim); -[~, rho2 mu2] = circ_moment(alpha,w,2,true,dim); +[~, rho2, mu2] = circ_moment(alpha,w,2,true,dim); % compute skewness theta2 = repmat(theta, size(alpha)./size(theta)); b = sum(w.*(sin(2*(circ_dist(alpha,theta2)))),dim)./sum(w,dim); b0 = rho2.*sin(circ_dist(mu2,2*theta))./(1-R).^(3/2); % (formula 2.29) - - +end diff --git a/circ_stats.m b/circ_stats.m index 6194907..8f32e09 100644 --- a/circ_stats.m +++ b/circ_stats.m @@ -52,15 +52,12 @@ stats.var = circ_var(alpha,w,d); % standard deviation -[stats.std stats.std0] = circ_std(alpha,w,d); +[stats.std, stats.std0] = circ_std(alpha,w,d); % skewness -[stats.skewness stats.skewness0] = circ_skewness(alpha,w); +[stats.skewness, stats.skewness0] = circ_skewness(alpha,w); % kurtosis -[stats.kurtosis stats.kurtosis0] = circ_kurtosis(alpha,w); - - - - +[stats.kurtosis, stats.kurtosis0] = circ_kurtosis(alpha,w); +end diff --git a/circ_std.m b/circ_std.m index 115ebd8..dfbbb6d 100644 --- a/circ_std.m +++ b/circ_std.m @@ -1,4 +1,4 @@ -function [s s0] = circ_std(alpha, w, d, dim) +function [s, s0] = circ_std(alpha, w, d, dim) % s = circ_std(alpha, w, d, dim) % Computes circular standard deviation for circular data % (equ. 26.20, Zar). @@ -52,6 +52,4 @@ s = sqrt(2*(1-r)); % 26.20 s0 = sqrt(-2*log(r)); % 26.21 - - - +end diff --git a/circ_symtest.m b/circ_symtest.m index 3c81372..e456585 100644 --- a/circ_symtest.m +++ b/circ_symtest.m @@ -34,7 +34,4 @@ % compute wilcoxon sign rank test pval = signrank(d); - - - - +end diff --git a/circ_var.m b/circ_var.m index 21013f7..7823bde 100644 --- a/circ_var.m +++ b/circ_var.m @@ -1,4 +1,4 @@ -function [S s] = circ_var(alpha, w, d, dim) +function [S, s] = circ_var(alpha, w, d, dim) % s = circ_var(alpha, w, d, dim) % Computes circular variance for circular data % (equ. 26.17/18, Zar). @@ -54,4 +54,5 @@ % apply transformation to var S = 1 - r; -s = 2 * S; \ No newline at end of file +s = 2 * S; +end diff --git a/circ_vmpar.m b/circ_vmpar.m index 75c40c8..8d1ab21 100644 --- a/circ_vmpar.m +++ b/circ_vmpar.m @@ -1,4 +1,4 @@ -function [thetahat kappa] = circ_vmpar(alpha,w,d) +function [thetahat, kappa] = circ_vmpar(alpha,w,d) % r = circ_vmpar(alpha, w, d) % Estimate the parameters of a von Mises distribution. @@ -36,3 +36,4 @@ kappa = circ_kappa(r); thetahat = circ_mean(alpha,w); +end diff --git a/circ_vmpdf.m b/circ_vmpdf.m index 4636a66..e8073dc 100644 --- a/circ_vmpdf.m +++ b/circ_vmpdf.m @@ -1,4 +1,4 @@ -function [p alpha] = circ_vmpdf(alpha, thetahat, kappa) +function [p, alpha] = circ_vmpdf(alpha, thetahat, kappa) % [p alpha] = circ_vmpdf(alpha, w, p) % Computes the circular von Mises pdf with preferred direction thetahat @@ -44,3 +44,4 @@ % evaluate pdf C = 1/(2*pi*besseli(0,kappa)); p = C * exp(kappa*cos(alpha-thetahat)); +end diff --git a/circ_vmrnd.m b/circ_vmrnd.m index c0e3e55..f7d9f6f 100644 --- a/circ_vmrnd.m +++ b/circ_vmrnd.m @@ -79,9 +79,4 @@ if exist('m','var') alpha = reshape(alpha,m(1),m(2)); end - - - - - - +end diff --git a/circ_vtest.m b/circ_vtest.m index 5abbb64..1410ccd 100644 --- a/circ_vtest.m +++ b/circ_vtest.m @@ -1,4 +1,4 @@ -function [pval v] = circ_vtest(alpha, dir, w, d) +function [pval, v] = circ_vtest(alpha, dir, w, d) % % [pval, v] = circ_vtest(alpha, dir, w, d) % Computes V test for non-uniformity of circular data with a specified @@ -75,3 +75,4 @@ % compute p-value from one tailed normal approximation pval = 1 - normcdf(u); +end diff --git a/circ_wwtest.m b/circ_wwtest.m index a92ff30..efef0fc 100644 --- a/circ_wwtest.m +++ b/circ_wwtest.m @@ -1,4 +1,4 @@ -function [pval table] = circ_wwtest(varargin) +function [pval, table] = circ_wwtest(varargin) % [pval, table] = circ_wwtest(alpha, idx, [w]) % [pval, table] = circ_wwtest(alpha1, alpha2, [w1, w2]) % Parametric Watson-Williams multi-sample test for equal means. Can be @@ -155,4 +155,3 @@ function checkAssumption(rw,n) error('Invalid use of circ_wwtest. Type help circ_wwtest.') end end - From 2a94a11f950f58df720d4648ccafaecbbf602aec Mon Sep 17 00:00:00 2001 From: Matt Krause Date: Sun, 18 Jun 2017 16:12:57 -0400 Subject: [PATCH 2/2] Changed defaults for dim arguments. Dim now defaults to the first non-singular dimension, rather than just the first. This matches most matlab functions a bit more closely. For example, circ_mean([0 2*pi]) and circ_mean([0 2*pi]') now both return pi, rather than [0 2*pi] and pi, depending. --- circ_axialmean.m | 7 +++++-- circ_confmean.m | 7 +++++-- circ_kurtosis.m | 7 +++++-- circ_mean.m | 7 +++++-- circ_median.m | 7 +++++-- circ_moment.m | 7 +++++-- circ_r.m | 7 +++++-- circ_skewness.m | 7 +++++-- circ_std.m | 7 +++++-- circ_var.m | 7 +++++-- 10 files changed, 50 insertions(+), 20 deletions(-) diff --git a/circ_axialmean.m b/circ_axialmean.m index 8796e16..dce22a2 100644 --- a/circ_axialmean.m +++ b/circ_axialmean.m @@ -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 @@ -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) diff --git a/circ_confmean.m b/circ_confmean.m index 40cf1cf..61203d1 100644 --- a/circ_confmean.m +++ b/circ_confmean.m @@ -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 @@ -28,7 +28,10 @@ % berens@tuebingen.mpg.de - 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) diff --git a/circ_kurtosis.m b/circ_kurtosis.m index d530ef8..23d8e97 100644 --- a/circ_kurtosis.m +++ b/circ_kurtosis.m @@ -6,7 +6,7 @@ % 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) @@ -25,7 +25,10 @@ % berens@tuebingen.mpg.de if nargin < 3 - dim = 1; + dim = find(size(alpha) > 1, 1, 'first'); + if isempty(dim) + dim = 1; + end end if nargin < 2 || isempty(w) diff --git a/circ_mean.m b/circ_mean.m index 6bdf747..c04f4f9 100644 --- a/circ_mean.m +++ b/circ_mean.m @@ -6,7 +6,7 @@ % 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) @@ -29,7 +29,10 @@ % berens@tuebingen.mpg.de - 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) diff --git a/circ_median.m b/circ_median.m index 70382d7..07b3ae8 100644 --- a/circ_median.m +++ b/circ_median.m @@ -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: @@ -25,7 +25,10 @@ % berens@tuebingen.mpg.de - 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); diff --git a/circ_moment.m b/circ_moment.m index 9e81286..368986f 100644 --- a/circ_moment.m +++ b/circ_moment.m @@ -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) @@ -29,7 +29,10 @@ % berens@tuebingen.mpg.de if nargin < 5 - dim = 1; + dim = find(size(alpha) > 1, 1, 'first'); + if isempty(dim) + dim = 1; + end end if nargin < 4 diff --git a/circ_r.m b/circ_r.m index c1c9aea..e2ce64e 100644 --- a/circ_r.m +++ b/circ_r.m @@ -8,7 +8,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] % % If dim argument is specified, all other optional arguments can be % left empty: circ_r(alpha, [], [], dim) @@ -29,7 +29,10 @@ % berens@tuebingen.mpg.de - www.kyb.mpg.de/~berens/circStat.html if nargin < 4 - dim = 1; + dim = find(size(alpha) > 1, 1, 'first'); + if isempty(dim) + dim = 1; + end end if nargin < 2 || isempty(w) diff --git a/circ_skewness.m b/circ_skewness.m index 6c563f3..3cc4a82 100644 --- a/circ_skewness.m +++ b/circ_skewness.m @@ -6,7 +6,7 @@ % 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_skewness(alpha, [], dim) @@ -25,7 +25,10 @@ % berens@tuebingen.mpg.de if nargin < 3 - dim = 1; + dim = find(size(alpha) > 1, 1, 'first'); + if isempty(dim) + dim = 1; + end end if nargin < 2 || isempty(w) diff --git a/circ_std.m b/circ_std.m index dfbbb6d..6f8f95c 100644 --- a/circ_std.m +++ b/circ_std.m @@ -9,7 +9,7 @@ % [d spacing of bin centers for binned data, if supplied % correction factor is used to correct for bias in % estimation of r] -% [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_std(alpha, [], [], dim) @@ -29,7 +29,10 @@ % berens@tuebingen.mpg.de - www.kyb.mpg.de/~berens/circStat.html if nargin < 4 - dim = 1; + dim = find(size(alpha) > 1, 1, 'first'); + if isempty(dim) + dim = 1; + end end if nargin < 3 || isempty(d) diff --git a/circ_var.m b/circ_var.m index 7823bde..91931d4 100644 --- a/circ_var.m +++ b/circ_var.m @@ -9,7 +9,7 @@ % [d spacing of bin centers for binned data, if supplied % correction factor is used to correct for bias in % estimation of r] -% [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_var(alpha, [], [], dim) @@ -31,7 +31,10 @@ % berens@tuebingen.mpg.de - www.kyb.mpg.de/~berens/circStat.html if nargin < 4 - dim = 1; + dim = find(size(alpha) > 1, 1, 'first'); + if isempty(dim) + dim = 1; + end end if nargin < 3 || isempty(d)