32 from scipy
import optimize
59 def cdf_weighted_chisq_Pinv(A, noncent, dof, var, P, lim, accuracy):
60 func =
lambda x: cdf_weighted_chisq_P(A, noncent, dof, var, x, lim, accuracy) - P
66 print >>sys.stderr, lo, hi
67 return optimize.brentq(func, lo, hi, xtol = accuracy * 4)
74 def max_stat_thresh(coeffs, fap, samp_tol=100.0):
75 num = int(samp_tol/ fap)
76 out = numpy.zeros(num)
77 for c
in coeffs: out += c*scipy.randn(num)**2
79 return float(out[-int(samp_tol)])
88 def ss_coeffs(S, amp=5.5):
89 return S**2. / (S**2. + len(S) / amp**2. )