# HG changeset patch # User jwe # Date 1093656579 0 # Node ID a0f2839f6ac83c50e92383f050f168e1378e4ce4 # Parent 6af62cc045f715c6ae870a8602e70b75aceb1339 [project @ 2004-08-28 01:29:39 by jwe] diff -r 6af62cc045f7 -r a0f2839f6ac8 scripts/ChangeLog --- a/scripts/ChangeLog Wed Aug 25 16:37:30 2004 +0000 +++ b/scripts/ChangeLog Sat Aug 28 01:29:39 2004 +0000 @@ -1,3 +1,8 @@ +2004-08-27 David Bateman + + * statistics/base/ranks.m: Handle non-consecutive ties. + Eliminate loop. + 2004-07-27 David Bateman * general/num2str.m: Also insert spaces in output when precision diff -r 6af62cc045f7 -r a0f2839f6ac8 scripts/statistics/base/ranks.m --- a/scripts/statistics/base/ranks.m Wed Aug 25 16:37:30 2004 +0000 +++ b/scripts/statistics/base/ranks.m Sat Aug 28 01:29:39 2004 +0000 @@ -71,20 +71,17 @@ endif sz = size (x); infvec = -Inf * ones ([1, sz(2 : end)]); - [xs, y] = sort (x); + [xs, xi] = sort (x); eq_el = find (diff ([xs; infvec]) == 0); if (isempty (eq_el)) - [eq_el, y] = sort (y); + [eq_el, y] = sort (xi); else runs = complement (eq_el+1, eq_el); - runs = reshape (y (runs), size (runs)) + floor (runs ./ sz(1)) * sz(1); len = diff (find (diff ([Inf; eq_el; -Inf]) != 1)) + 1; - [eq_el, y] = sort (y); + [eq_el, y] = sort (xi); for i = 1 : length(runs) - p = y(runs(i)) + (len(i) - 1) / 2; - for j = 0 : len(i) - 1 - y(runs(i) + j) = p; - endfor + y (xi (runs (i) + [0:(len(i)-1)]) + floor (runs (i) ./ sz(1)) + * sz(1)) = eq_el(runs(i)) + (len(i) - 1) / 2; endfor endif if (dim != 1)