threshold.m
上传用户:szahd2008
上传日期:2020-09-25
资源大小:1275k
文件大小:1k
- function [pfa, vt] = threshold (nfa, np)
- % This function calculates the threshold value from nfa and np.
- % The newton-Raphson recursive formula is used
- % This function uses "incomplete_gamma.m".
- delmax = .00001;
- eps = 0.000000001;
- delta =10000.;
- pfa = np * log(2) / nfa;
- sqrtpfa = sqrt(-log10(pfa));
- sqrtnp = sqrt(np);
- vt0 = np - sqrtnp + 2.3 * sqrtpfa * (sqrtpfa + sqrtnp - 1.0);
- vt = vt0;
- while (abs(delta) >= vt0)
- igf = incomplete_gamma(vt0,np);
- num = 0.5^(np/nfa) - igf;
- temp = (np-1) * log(vt0+eps) - vt0 - factor(np-1);
- deno = exp(temp);
- vt = vt0 + (num / (deno+eps));
- delta = abs(vt - vt0) * 10000.0;
- vt0 = vt;
- end
-