Mercurial > hg > octave-nkf
changeset 4942:a0f2839f6ac8
[project @ 2004-08-28 01:29:39 by jwe]
author | jwe |
---|---|
date | Sat, 28 Aug 2004 01:29:39 +0000 |
parents | 6af62cc045f7 |
children | 1a499d0c58f5 |
files | scripts/ChangeLog scripts/statistics/base/ranks.m |
diffstat | 2 files changed, 10 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,8 @@ +2004-08-27 David Bateman <dbateman@free.fr> + + * statistics/base/ranks.m: Handle non-consecutive ties. + Eliminate loop. + 2004-07-27 David Bateman <dbateman@free.fr> * general/num2str.m: Also insert spaces in output when precision
--- a/scripts/statistics/base/ranks.m +++ b/scripts/statistics/base/ranks.m @@ -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)