HS2SIGN Calculates a ratio-significant value of a histogram. CALL: cs = hs2sign(f); CALL: cs = hs2sign(f,ratio); cs = a three column matrix with ratio in the first column the ratio-significant value of H in the second and a ratio-quantile in the third column. f = a two column matrix containing the histogram. ratio = a constant (0<ratio<1) defining the significant value, (optional input, only one significant value is computed).
001 function hs=hs2sign(f,ratio); 002 % HS2SIGN Calculates a ratio-significant value of a histogram. 003 % 004 % CALL: cs = hs2sign(f); 005 % CALL: cs = hs2sign(f,ratio); 006 % 007 % cs = a three column matrix with ratio in the first column 008 % the ratio-significant value of H in the second and 009 % a ratio-quantile in the third column. 010 % f = a two column matrix containing the histogram. 011 % ratio = a constant (0<ratio<1) defining the significant value, 012 % (optional input, only one significant value is computed). 013 014 [y index]=sort(f(:,1)); 015 f=f(index,:); 016 Hs=cumsum(f(:,2)); 017 018 if (nargin<2) 019 f=flipud(f); 020 Hs=cumsum(f(:,2)); 021 index=find(Hs>0); 022 f=f(index,:); 023 Hs=cumsum(f(:,2)); 024 Fs=flipud(cumsum(f(:,2).*f(:,1))./Hs); 025 026 N=length(Hs); 027 028 NN=sum(f(:,2)); 029 030 hs=ones(N,3); 031 hs(:,1)=flipud(Hs)./NN; 032 hs(:,2)=Fs; 033 hs(:,3)=flipud(f(:,1)); 034 else 035 if ratio <= 0 036 error('ratio must be >0.') 037 break 038 end 039 if ratio >= 1 040 error('ratio must be <1.') 041 end 042 hs=min(Hs./sum(f(:,2)),ones(length(Hs),1).*ratio); 043 dhs=abs(diff([0; f(:,1)]')); 044 hs=[ratio dhs*hs/ratio]; 045 end 046
Comments or corrections to the WAFO group