def CalcLikelihood(gsq, m_med, event_list): #Poisson likelihood No = len(event_list) Ne = CalcNevents(gsq, m_med, tab=True) PL = -Ne + No * np.log(Ne) for i in range(No): PL += np.log(exposure*CEvNS.differentialRate_CEvNS(event_list[i],\ A_Ge, Z_Ge, gsq, m_med,tab=True)/Ne) return PL * 1.0 / Tchain
def GenerateEvents(N_exp): No = np.random.poisson(lam=N_exp) print " N_obs = ", No events = np.zeros(No) Rmax = CEvNS.differentialRate_CEvNS(E_min, A_Ge, Z_Ge) #Get the inverse cumulative distribution Evals = np.logspace(np.log10(E_min), np.log10(E_max), 100) dRdE = np.vectorize(CEvNS.differentialRate_CEvNS) Rvals = dRdE(Evals, A_Ge, Z_Ge) Rcum = cumtrapz(Rvals, Evals, initial=0.0) Rcum = Rcum / Rcum[-1] fx = interp1d(Rcum, Evals) xvals = np.random.rand(No) return fx(xvals) #Slow rejection method """
def CalcNevents(gsq=0.0, m_med=1000.0, tab=False): integ = lambda x: CEvNS.differentialRate_CEvNS(x,\ A_Ge, Z_Ge, gsq, m_med, tab) return exposure * quad(integ, E_min, E_max, epsrel=1e-4)[0]
#pl.loglog(Q_list, lnL) #pl.axhline(3.84, linestyle=":") #pl.show() return np.min(Q_list[lnL > 3.84]) #----Main Procedure---- print " " print "****************************" print "* LimitCalculator.py *" print "****************************" print " " print " Calculating Z-prime limits..." print " NB: perturbativity limit is Q_Z'=", 12.0 * np.pi * A_Ge """ Qv = (A_Ge-Z_Ge) G_FERMI = 1.1664e-5 SQRT2 = np.sqrt(2.0) qsq = 2*0.9315*A_Ge def G_V(QvNP, m_med): return 1e6*(SQRT2/G_FERMI)*(QvNP/Qv)*1.0/(qsq + m_med*m_med) m_medlist = np.logspace(0.0, 7.0) Qlist = np.logspace(-10, np.log10(12.0*np.pi*A_Ge)) #Glist = G_V(12.0*np.pi*A_Ge, m_medlist) #print m_medlist, Glist