Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package octave-forge-nan for 
openSUSE:Factory checked in at 2021-11-18 10:33:58
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/octave-forge-nan (Old)
 and      /work/SRC/openSUSE:Factory/.octave-forge-nan.new.1895 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "octave-forge-nan"

Thu Nov 18 10:33:58 2021 rev:14 rq:931972 version:3.6.1

Changes:
--------
--- /work/SRC/openSUSE:Factory/octave-forge-nan/octave-forge-nan.changes        
2021-09-22 22:13:12.780335786 +0200
+++ 
/work/SRC/openSUSE:Factory/.octave-forge-nan.new.1895/octave-forge-nan.changes  
    2021-11-18 10:34:00.091916779 +0100
@@ -1,0 +2,8 @@
+Fri Nov 12 23:04:59 UTC 2021 - Atri Bhattacharya <[email protected]>
+
+- Update to version 3.6.1:
+  * signrank: update computation of p-value according to revised
+    references, and validated against R.
+  * cdfplot: use histo instead of histo_mex.
+
+-------------------------------------------------------------------

Old:
----
  nan-3.6.0.tar.gz

New:
----
  nan-3.6.1.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ octave-forge-nan.spec ++++++
--- /var/tmp/diff_new_pack.6q2LQe/_old  2021-11-18 10:34:00.523917181 +0100
+++ /var/tmp/diff_new_pack.6q2LQe/_new  2021-11-18 10:34:00.527917184 +0100
@@ -18,7 +18,7 @@
 
 %define octpkg  nan
 Name:           octave-forge-%{octpkg}
-Version:        3.6.0
+Version:        3.6.1
 Release:        0
 Summary:        A statistics and machine learning toolbox
 License:        GPL-3.0-or-later

++++++ nan-3.6.0.tar.gz -> nan-3.6.1.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/nan-3.6.0/DESCRIPTION new/nan-3.6.1/DESCRIPTION
--- old/nan-3.6.0/DESCRIPTION   2021-07-26 16:19:19.000000000 +0200
+++ new/nan-3.6.1/DESCRIPTION   2021-11-03 21:09:44.000000000 +0100
@@ -1,6 +1,6 @@
 Name: NaN
-Version: 3.6.0
-Date: 2021-07-26
+Version: 3.6.1
+Date: 2021-11-03
 Author: Alois Schl??gl <[email protected]>
 Maintainer: Alois Schl??gl
 Title: The NaN-toolbox
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/nan-3.6.0/NEWS new/nan-3.6.1/NEWS
--- old/nan-3.6.0/NEWS  2021-07-26 16:19:19.000000000 +0200
+++ new/nan-3.6.1/NEWS  2021-11-03 21:09:44.000000000 +0100
@@ -1,3 +1,12 @@
+
+2021-11-03: Release of NaN-toolbox 3.6.1
+
+* signrank: update computation of p-value
+    according to revised references,
+    and validated against R.
+* cdfplot: use histo instead of histo_mex
+
+
 2021-07-26: Release of NaN-toolbox 3.6.0
 
 * corrplot, knnsearch <NEW>
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/nan-3.6.0/inst/cdfplot.m new/nan-3.6.1/inst/cdfplot.m
--- old/nan-3.6.0/inst/cdfplot.m        2021-07-26 16:19:19.000000000 +0200
+++ new/nan-3.6.1/inst/cdfplot.m        2021-11-03 21:09:44.000000000 +0100
@@ -40,7 +40,7 @@
 % Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, 
USA.
 
 
-his = histo_mex(X(:));
+his = histo(X(:));
 cdf = cumsum(his.H,1) ./ sum(his.H,1);
 ix1 = ceil ([1:2*size(his.X,1)]'/2);  
 ix2 = floor([2:2*size(his.X,1)]'/2);  
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/nan-3.6.0/inst/signrank.m 
new/nan-3.6.1/inst/signrank.m
--- old/nan-3.6.0/inst/signrank.m       2021-07-26 16:19:19.000000000 +0200
+++ new/nan-3.6.1/inst/signrank.m       2021-11-03 21:09:44.000000000 +0100
@@ -1,50 +1,50 @@
 function [pval, h, stats] = signrank (x, m, alpha, tail, DIM)
 % SIGNRANK - Wilcoxon signed-rank test
-%     The Wilcoxon signed-rank test is a non-parametric statistical hypothesis 
-%     test used to compare two related samples whether their population median 
-%     ranks differ [1-3]. SIGNRANK treads NaNs as "Missing values" and ignores 
these. 
-%     Octave's statistical package has also wilcoxon_test, however, this works 
only 
-%     for data with N>25 samples, signrank is based on the works [1-3] and can 
-%     be used also for smaller sample sizes.
-%
-% pval = signrank(x,m)
-%      tests Null-hypothesis that median of x is m.            
-% pval = signrank(x,y)
-%      size of x and size of y must match, it is tested whether the 
-%      difference x-y is significantly different to m=0; 
+%     The Wilcoxon signed-rank test is a non-parametric statistical hypothesis
+%     test used to compare two related samples whether their population median
+%     ranks differ [1-4]. SIGNRANK treads NaNs as "Missing values" and ignores 
these.
+%     The current implementation has been validated against wilcox.test of R 
(v4.0.4).
+%
+% pval = signrank(X,m [, ...])
+%      tests Null-hypothesis that median of x is m.
+%       size(m,DIM) must be one, all other dimensions must match those of X
+% pval = signrank(x,y [, ...])
+%      size of x and size of y must match, it is tested whether the
+%      difference x-y is significantly different to m=0;
 % pval = signrank(x,y,alpha)
 % pval = signrank(x,y,alpha,tail)
 % pval = signrank(x,y,alpha,tail,DIM)
 % [pval,H,stats] = signrank(...)
 %
-%     H=1 indicates a rejection of the Null-hypothesis at a significance 
-%     level of alpha (default alpha = 0.05).    
-% 
+%     H=1 indicates a rejection of the Null-hypothesis at a significance
+%     level of alpha (default alpha = 0.05).
+%
 %     With the optional argument string TAIL, the alternative of interest
 %     can be selected.  If TAIL is '!=' or '<>' or 'both', the null is tested
 %     against the two-sided Alternative `mean (X) ~= mean (Y)'.  If TAIL
 %     is '>' or 'right', the one-sided Alternative `mean (X) > mean (Y)' is 
used.
 %     Similarly for '<' or 'left', the one-sided Alternative `mean (X) < mean
 %     (Y)' is used.  The default is the two-sided case.
-% 
-%     H returns whether the Null-Hypotheses must be rejected. 
-%     The p-value of the test is returned in PVAL. 
-% 
-%     signrank works on the first non-singleton dimension or on DIM. 
+%
+%     H returns whether the Null-Hypotheses must be rejected.
+%     The p-value of the test is returned in PVAL.
+%
+%     signrank works on the first non-singleton dimension of X and Y, or on 
DIM.
 %
 %     If no output argument is given, the p-value of the test is
 %     displayed.
 %
-% Reference(s): 
+% Reference(s):
 % [1] Glenn A Walker, (2002)
-%     Common Statistical Methods for Clinical Research (with SAS examples), 
2nd edition                
+%     Common Statistical Methods for Clinical Research (with SAS examples), 
2nd edition
 %     Chapter 12 The Wilcoxon Signed-Rank Test.
 % [2] https://en.wikipedia.org/wiki/Wilcoxon_signed-rank_test
 % [3] 
https://math.stackexchange.com/questions/1414794/wilcoxon-signed-rank-test
+% [4] https://de.wikipedia.org/wiki/Wilcoxon-Vorzeichen-Rang-Test
 
-%       Copyright (C) 2010,2019 by Alois Schloegl <[email protected]>   
-%       This function is part of the NaN-toolbox
-%       http://pub.ist.ac.at/~schloegl/matlab/NaN/
+%    Copyright (C) 2010,2019,2021 by Alois Schloegl <[email protected]>
+%    This function is part of the NaN-toolbox
+%    http://pub.ist.ac.at/~schloegl/matlab/NaN/
 
 %    This program is free software: you can redistribute it and/or modify
 %    it under the terms of the GNU General Public License as published by
@@ -73,7 +73,10 @@
   if (nargin < 4) || isempty(tail)
     tail = '~=';
   end
-  if (~ ischar (tail))
+  if (~isnumeric(alpha))
+    error ('signrank: alpha must be numeric');
+  end
+  if (~ischar(tail))
     error ('signrank: tail must be a string');
   end
   if nargin<5,
@@ -81,74 +84,143 @@
   end;
   if isempty(DIM), DIM=1; end;
 
-  szx = size(x); 
-  szm = size(m);       
-  szx(DIM) = 1;          
+  szx = size(x);
+  szm = size(m);
+  szx(DIM) = 1;
   szm(DIM) = 1;
   if size(m,DIM)==1
-       ;
+       x = x-repmat(m,size(x)./szx);
   elseif size(x,DIM) == size(m,DIM)
        x = x-m;
        m = zeros(szm);
   else
-    error ('signrank: dimension of X and Y do not fit');
-  end    
-  
-  % Algorithm according to 
-  % https://en.wikipedia.org/wiki/Wilcoxon_signed-rank_test
-
-  % Step 2: exclude 0, and get N_r
-  x(abs(x)==0)=NaN; 
-  Nr=sum(~isnan(x),DIM);
+        error ('signrank: dimension of X and Y do not fit');
+  end
+
+  % Algorithm using "signed rank procedure" [2]
+  x(x==0)=NaN;
+  Nr=sum(~isnan(x) & (x~=0), DIM);
 
-  % Step 3 and 4: Order and Rank the data
-  Rix = tiedrank(abs(x));
+  % Order and Rank the data using "modified ranks" [2]
+  Rix = tiedrank(abs(x), DIM);
 
-  % Glenn A Walker [3]
-  % compute correction for ties; 
+  % Glenn A Walker [3,4]: compute correction for ties; 
   sz  = size(x);
   P   = [DIM,1:DIM-1,DIM+1:length(sz)];
-  HIS = histo2(reshape(permute(Rix,P),sz(DIM),sz([1:DIM-1,DIM+1:end])));       
-  m   = HIS.H; 
+  HIS = histo2(reshape(permute(Rix,P),sz(DIM),prod(sz([1:DIM-1,DIM+1:end]))));
+  m   = HIS.H;
   m(HIS.H<=1) = NaN;
   C   = 
ipermute(reshape(sumskipnan(m.*(m-1).*(m+1),1),[1,sz([1:DIM-1,DIM+1:end])]),P);
 
-  %Step 5:
-  W = sum(sign(x).*Rix,DIM);
-  % z = W./sqrt(Nr.*(Nr+1).*(2*Nr+1)./(6*(Nr-1)));
+  W   = sumskipnan(sign(x).*Rix,DIM);
+  z   = W./sqrt(Nr.*(Nr+1).*(2*Nr+1)/6 - C/12);
+  p2  = 2*abs(W)./(Nr.*Nr);
 
   % https://math.stackexchange.com/questions/1414794/wilcoxon-signed-rank-test
-  Tplus  = sumskipnan((x>0).*Rix, DIM);
-  Tminus = sumskipnan((x<0).*Rix, DIM);
+  Tplus  = sumskipnan((x>0) .* Rix, DIM);
+  Tminus = sumskipnan((x<0) .* Rix, DIM);
 
-  stats.z = (max(Tplus,Tminus)-Nr.*(Nr+1)/4)./sqrt(Nr.*(Nr+1).*(2*Nr+1)./24);
-  stats.signedrank = max(Tplus,Tminus);
-  
-  S   = (Tplus - Tminus) / 2;
-  V   = (Nr.* (Nr+1).*(2*Nr+1) - C/2) / 24;
-  t   = S .* sqrt(max(Nr-1,0)) ./ sqrt(Nr.*V - S.*S);
-  cdf = tcdf(t, Nr);
+  stats.signedrank  = min(Tplus, Tminus);
+  #
+  # simple formula is:
+  #     z = (Tplus - Nr.*(Nr+1)/4)./sqrt(Nr.*(Nr+1).*(2*Nr+1)/24);
+  # but for approximation for N<60, and ties (see [4])
+  #     z = (abs(Tplus - Nr.*(Nr+1)/4)-0.5)./sqrt(Nr.*(Nr+1).*(2*Nr+1)/24 - 
C/48);
+  V = sqrt(Nr.*(Nr+1).*(2*Nr+1)./24 - C/48);
+
+  stats.z = z;
+  % effective size [2] 
+  stats.r = 2*(Tplus-Tminus)./(Nr.*(Nr+1));
 
-  % see also NaN/ttest  
+  % see also NaN/ttest
   if (strcmp (tail, '~=') || strcmp (tail, '!=') || strcmp (tail, '<>')) || 
strcmp(tail,'both'),
+    z    = -(abs(Tplus  - Nr.*(Nr+1)/4) - .5) ./ V;
+    cdf  = normcdf(z);
     pval = 2 * min (cdf, 1 - cdf);
   elseif strcmp (tail, '>') || strcmp(tail,'right'),
-    pval = 1 - cdf;
+    z    = -(Tplus  - Nr.*(Nr+1)/4 - .5) ./ V;
+    pval = normcdf(z);
   elseif strcmp (tail, '<') || strcmp(tail,'left'),
-    pval = cdf;
+    z    = -(Tminus - Nr.*(Nr+1)/4 - .5) ./ V;
+    pval = normcdf(z);
   else
     error ('signrank: option %s not recognized', tail);
   end
 
-  h = pval < alpha;    
+  h = pval < alpha;
   if (nargout == 0)
     fprintf(1,'  pval: %g\n', pval);
   end
-  stats.t=t;   
 
 %!test
-%! % example from [3] 
-%! x = 
[15,8;10,3;6,7;5,13;10,2;15,12;7,14;5,8;8,13;12,3;4,9;13,3;8,10;10,2;11,4;13,7;6,1;6,11;,9,3;
 5,5;10,2;9,8;11,5;8,8]; 
+%! x = 
[15,8;10,3;6,7;5,13;10,2;15,12;7,14;5,8;8,13;12,3;4,9;13,3;8,10;10,2;11,4;13,7;6,1;6,11;,9,3;
 5,5;10,2;9,8;11,5;8,8];
 %! [p,h,stats] = signrank( x(:,1), x(:,2) );
-%! assert ( abs(stats.t - 2.184) < .01)
+%! assert ( abs(p - 0.045350) < 1e-6)
+%!
+%!test
+%! [p,h,stats]=signrank([1:15]',8);
+%! assert ( h==0 )
+%!
+%!test
+%! [p,h,stats]=signrank([17.6, 20.6, 22.2, 15.3, 20.9, 21.0, 18.9, 18.9, 18.9, 
18.2]',25);
+%! assert ( abs(p - 0.005793) < 1e-5)
+%!
+%!test
+%! [p,h,stats]=signrank([17.6, 20.6, 22.2, 15.3, 20.9, 21.0, 18.9, 18.9, 18.9, 
18.2]',25,[],'<');
+%! assert ( abs(p - 2.8965e-03) < 1e-6)
+%!
+%!test
+%! [p,h,stats]=signrank([17.6, 20.6, 22.2, 15.3, 20.9, 21.0, 18.9, 18.9, 18.9, 
18.2]', 25, [], '>');
+%! assert ( abs(p - 0.9979) < 1e-5)
+%!
+%!test
+%! [p,h,stats]=signrank([17.6, 20.6, 22.2, 15.3, 20.9, 21.0, 18.9, 18.9, 18.9, 
18.2]', 19);
+%! assert ( abs(p - 0.838) < 1e-4)
+%!
+%!test
+%! [p,h,stats]=signrank([17.6, 20.6, 22.2, 15.3, 20.9, 21.0, 18.9, 18.9, 18.9, 
18.2]', 19, [], '<');
+%! assert ( abs(p - 0.6204) < 1e-4)
+%!
+%!test
+%! [p,h,stats]=signrank([17.6, 20.6, 22.2, 15.3, 20.9, 21.0, 18.9, 18.9, 18.9, 
18.2]', 19, [], '>');
+%! assert ( abs(p - 0.419) < 1e-4)
+%!
+%!test
+%! [p,h,stats]=signrank([0, 2, 3, 4, 6, 7, 8, 9, 11, 14, 15, 17, -18]+1,1);
+%! assert ( abs(p - 0.037633) < 1e-6)
+%!
+%!test
+%! [p,h,stats]=signrank([0, 2, 3, 4, 6, 7, 8, 9, 11, 14, 15, 17, -18],0);
+%! assert ( abs(p - 0.037633) < 1e-6)
+%!
+%!test
+%! [p,h,stats]=signrank([   2, 3, 4, 6, 7, 8, 9, 11, 14, 15, 17, -18],0);
+%! assert ( abs(p - 0.037633) < 1e-6)
+%!
+%!test
+%! [p,h,stats]=signrank([-1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,-13],0);
+%! assert ( abs(p - 0.030276) < 1e-6)
+%!
+%!test
+%! [p,h,stats]=signrank([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, -12],0);
+%! assert ( abs(p - 0.037633) < 1e-6)
+%!
+%!test
+%! x = [125    110;115 122;130 125;140 120;140 140;115 124;140 123;125 137;140 
135;135 145];
+%! [p,h,stats] = signrank( x(:,1), x(:,2) );
+%%! assert ( abs(p - 0.6113) < 1e-4)   % this does not match [2]
+%! assert ( abs(p - 0.6353) < 1e-4)    % matches the result in R
+%!
+%!test
+%! x = [4      1;3     2; 2    3; 5    0; 5    0; 3    2];
+%! [p,h,stats] = signrank( x(:,1), x(:,2) );
+%!
+%!test
+%! SZ = [100,5,3]; X=round(rand(SZ)*10); Y=round(rand(SZ)*10);
+%! p1 = signrank(X,Y,1,[],1);
+%! assert(size(p1,2)==SZ(2) && size(p1,3)==SZ(3))
+%! p2 = signrank(X,Y,1,[],2);
+%! assert(size(p2,1)==SZ(1) && size(p2,3)==SZ(3))
+%! p3 = signrank(X,Y,1,[],3);
+%! assert(size(p3,2)==SZ(2) && size(p3,1)==SZ(1))
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/nan-3.6.0/inst/tiedrank.m 
new/nan-3.6.1/inst/tiedrank.m
--- old/nan-3.6.0/inst/tiedrank.m       2021-07-26 16:19:19.000000000 +0200
+++ new/nan-3.6.1/inst/tiedrank.m       2021-11-03 21:09:44.000000000 +0100
@@ -1,15 +1,14 @@
-function R=tiedrank(X,flag1,flag2)
+function R = tiedrank(X, DIM)
 % TIEDRANK compute rank of samples, the mean value is used in case of ties
 %  this function is just a wrapper for RANKS, and provided for compatibility 
 %  with the statistics toolbox of matlab(tm)
 % 
-%    R = tiedrank(X)
+%    R = tiedrank(X [,DIM] )
 %      computes the rank R of vector X
 %    
 % see also: RANKS
 
-
-%      Copyright (C) 2009,2010,2017 by Alois Schloegl 
<[email protected]>       
+%    Copyright (C) 2009,2010,2017,2021 by Alois Schloegl 
<[email protected]>
 %       This function is part of the NaN-toolbox
 %       http://pub.ist.ac.at/~schloegl/matlab/NaN/
 
@@ -27,28 +26,18 @@
 %    along with this program; If not, see <http://www.gnu.org/licenses/>.
 
 
-if nargin>3,
+if nargin>2,
        error('more than 3 input argument is currently not supported ')
-end;   
-if nargin<2,
-       flag1=0;
 end;
-if nargin<3,
-       flag2=0;
-end;
-
-if nargout>2,
-       warning('more than 1 output argument is currently not supported ')
-end;   
 
 if nargin<2,
         DIM = [];
 end;
 if isempty(DIM),
-        DIM = find(size(X)>1,1);
+        DIM = find(size(X)>1, 1);
         if isempty(DIM), DIM = 1; end;
 end
 if (DIM<1), DIM = 1; end; %% Hack, because min([])=0 for FreeMat v3.5
 
-R = ranks(X,DIM); 
+R = ranks(X,DIM);
 

Reply via email to