threshold.m
来自「模式识别工具箱,希望对大家有用!」· M 代码 · 共 35 行
M
35 行
function thr = threshold(d,fracrej)
%THRESHOLD Find percentile value for dataset
%
% thr = threshold(d,frac)
%
% Find the threshold for the data d. The lowest frac*100% of the
% data is rejected. This method is therefore first aimed at thresholds
% for density estimates. When the highest frac*100% of the data
% should be rejected, you have to use: thr = -threshold(-d,frac).
% (prctile in the statistics toolbox can also be used)
% Copyright: D. Tax, R.P.W. Duin, davidt@ph.tn.tudelft.nl
% Faculty of Applied Physics, Delft University of Technology
% P.O. Box 5046, 2600 GA Delft, The Netherlands
[nr,dim] = size(d);
if (dim>1)
error('threshold function is expecting a 1D array');
end
if ((fracrej<0)|(fracrej>1))
error('fracrej in threshold should be between 0 and 1');
end
d = sort(d);
frac = round(fracrej*nr);
if (frac==0)
thr = d(1);
else
if (frac==nr)
thr = d(nr);
else
thr = (d(frac) + d(frac+1))/2;
end
end
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?