1 % NANINSTTEST checks whether the functions from NaN-toolbox have been
6 % $Id: naninsttest.m 8223 2011-04-20 09:16:06Z schloegl $
7 % Copyright (C) 2000-2003 by Alois Schloegl <alois.schloegl@gmail.com>
8 % This script is part of the NaN-toolbox
9 % http://pub.ist.ac.at/~schloegl/matlab/NaN/
11 % This program is free software; you can redistribute it and/or modify
12 % it under the terms of the GNU General Public License as published by
13 % the Free Software Foundation; either version 3 of the License, or
14 % (at your option) any later version.
16 % This program is distributed in the hope that it will be useful,
17 % but WITHOUT ANY WARRANTY; without even the implied warranty of
18 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 % GNU General Public License for more details.
21 % You should have received a copy of the GNU General Public License
22 % along with this program; If not, see <http://www.gnu.org/licenses/>.
29 % run test, k=1: with NaNs, k=2: all NaN's are removed
30 % the result of both should be the same.
32 %FLAG_WARNING = warning;
35 funlist = {'sumskipnan','mean','std','var','skewness','kurtosis','sem','median','mad','zscore','coefficient_of_variation','geomean','harmmean','meansq','moment','rms','','corrcoef','rankcorr','spearman','ranks','center','trimean','min','max','tpdf','tcdf','tinv','normpdf','normcdf','norminv','nansum','nanstd','histo_mex','sumskipnan_mex','covm_mex','svmtrain_mex','train','','','','','','','',''};
37 if k==2, x(isnan(x))=[]; end;
38 r(1,k) =sumskipnan(x(1));
49 if exist('coefficient_of_variation','file'),
50 r(11,k)=coefficient_of_variation(x);
54 if exist('meansq','file'),
57 if exist('moment','file'),
60 if exist('rms','file'),
63 % r(17,k) is currently empty.
64 tmp=corrcoef(x',(1:length(x))');
65 r(18,k)=any(isnan(tmp(:)));
66 if exist('rankcorr','file'),
67 tmp=rankcorr(x',(1:length(x))');
68 r(19,k)=any(isnan(tmp(:)));
70 if exist('spearman','file'),
71 tmp=spearman(x',(1:length(x))');
72 r(20,k)=any(isnan(tmp(:)));
74 if exist('ranks','file'),
75 r(21,k)=any(isnan(ranks(x')))+k;
77 if exist('center','file'),
81 if exist('trimean','file'),
87 r(26,k) = k+isnan(tpdf(x(2),4));
90 r(27,k) = k*(~isnan(tcdf(nan,4)));
95 r(28,k) = k*(~isnan(tinv(NaN,4)));
97 if exist('normpdf','file'),
99 elseif exist('normal_pdf','file'),
102 r(29,k) = (feval(fun,k,k,0)~=Inf)*k;
103 if exist('normcdf','file'),
105 elseif exist('normal_cdf','file'),
108 r(30,k) = feval(fun,4,4,0);
109 if exist('norminv','file'),
111 elseif exist('normal_inv','file'),
114 r(31,k) = k*any(isnan(feval(fun,[0,1],4,0)));
115 if exist('nansum','file'),
116 r(32,k)=k*isnan(nansum(nan));
118 if exist('nanstd','file'),
119 r(33,k)=k*(~isnan(nanstd(0)));
130 sumskipnan_mex([1:5]');
141 if ~exist('svmtrain_mex','file'),
144 if ~exist('train','file'),
149 % check if result is correct
150 tmp = abs(r(:,1)-r(:,2))<eps;
155 if all(tmp(1:32)) && all(~q),
156 fprintf(1,'NANINSTTEST successful - your NaN-tools are correctly installed\n');
158 fprintf(1,'Warning: the following mex-files are not (properly) compiled:\n');
159 for k=find(~tmp(34:38)'),
160 fprintf(1,' %s.mex \n',funlist{k+33});
162 fprintf(1,'run \n mex -setup\n cd .../NaN/src\n make \n');
165 fprintf(1,'NANINSTTEST %i not successful \n', find(~tmp));
166 fprintf(1,'The following functions contain a NaN-related bug:\n');
167 fprintf(1,' - %s\n',funlist{find(~tmp)});
168 fprintf(1,'Its recommended to install the NaN-toolbox.\n');
171 %warning(FLAG_WARNING);