0001 function [iy,y,ym,ys,yr,iyr] = statanalysis_yp(yin,yt,display_mode)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023 if nargin < 3,
0024 display_mode = 0;
0025 end
0026
0027 if nargin < 2,
0028 yt = NaN;
0029 end
0030
0031 nyin = length(yin);
0032 y = yin;
0033 ny = nyin;
0034
0035 ymask = true(1,ny);
0036
0037 ym = mean(y);
0038 ys = std(y);
0039 yd = ny*ys/ym;
0040 yr = Inf;
0041
0042 while ny > 1,
0043
0044 iyc = find(abs(y - ym) == max(abs(y - ym)),1,'first');
0045
0046 y(iyc) = [];
0047
0048 ymc = mean(y);
0049 ysc = std(y);
0050 ydc = ny*ysc/ymc;
0051
0052 yr = abs(yd - ydc);
0053
0054 if isnan(yt),
0055 yrmax = 3*ys/ym;
0056 else
0057 yrmax = yt;
0058 end
0059
0060 if yr <= yrmax,
0061 break
0062 end
0063
0064
0065
0066 yind = find(ymask);
0067 ymask(yind(iyc)) = false;
0068 ny = ny - 1;
0069
0070 ym = ymc;
0071 ys = ysc;
0072 yd = ny*ys/ym;
0073
0074 end
0075
0076 iy = find(ymask);
0077 iyr = find(~ymask);
0078 y = yin(ymask);
0079
0080 if display_mode >= 2,
0081
0082 figure(1),clf
0083
0084 graph1D_jd(1:nyin,yin/ym,0,0,'n','y/ym','',NaN,[0,nyin+1],NaN,'-','+','r',2,20+14i,gca,0.9,0.7,0.7);
0085 graph1D_jd(iy,y/ym,0,0,'','','',NaN,[0,nyin+1],NaN,'none','o','b',2,20+14i);
0086
0087 graph1D_jd([0,nyin+1],[1+yrmax,1+yrmax],0,0,'','','',NaN,[0,nyin+1],NaN,'--','none','k',2,20+14i);
0088 graph1D_jd([0,nyin+1],[1-yrmax,1-yrmax],0,0,'','','',NaN,[0,nyin+1],NaN,'--','none','k',2,20+14i);
0089
0090 graph1D_jd([0,nyin+1],[1+ys/ym,1+ys/ym],0,0,'','','',NaN,[0,nyin+1],NaN,'--','none','g',2,20+14i);
0091 graph1D_jd([0,nyin+1],[1-ys/ym,1-ys/ym],0,0,'','','',NaN,[0,nyin+1],NaN,'--','none','g',2,20+14i);
0092
0093 end
0094
0095