def NLL(coord): ''' Returns the Negative Log Likelihood (NLL) for a taken tau (coord) value from a PDF evaluated with a fixed set of 10000 t,sigma data (see "from data import...") and the arg (coord) value. Args: coord: A list containing the floating point tau value(s) for which the NLL is computed Returns: NLL: The value of the NLL computed from the (t,sigma) dataset and input tau argument Example:>>> NLL([0.404]) 6220.45362533 >>> taulist = np.linspace(0.05,1,80) >>> NLL([taulist]) array([ 24155.94552593, 20743.52029484, 18165.04338598, ..., 8687.56466064, 8750.85271077, 8814.00166559]) ''' tau = coord[0] #Likelihood LL = 0. for i in range(0, len(t)): #Calculate the PDF for each t,sigma value and the tau value P = fitSig(t[i], sigma[i], tau) #Convert the evaluated PDF for each (t,sigma) measurement into natural log form logP = np.log(P) #Sum all the negative log P to give the LL (positive log likelihood) LL += logP NLL = -LL return NLL
def NLL5000(coord): ''' Returns the Negative Log Likelihood (NLL) for a taken tau (coord) value from a PDF evaluated with only the first 5000 data from a fixed set of t,sigma data (see "from data import...") and the arg (coord) value. Args: coordlist: A list containing the floating point tau value(s) for which the NLL is computed and integer value for which the dataset to draw measurements from is limited to Returns: NLL: The value of the NLL computed from the limited (t,sigma) dataset and input tau argument Example:>>> NLL5000([0.404]) # 3091.461273131531 ''' tau = coord[0] #Likelihood LL = 0. for i in range(0, len(t[:5000])): #Calculate the PDF for each t,sigma value and the tau value P = fitSig(t[i], sigma[i], tau) #Convert the evaluated PDF for each (t,sigma) measurement into natural log form logP = np.log(P) #Sum all the negative log P to give the LL (positive log likelihood) LL += logP NLL = -LL return NLL
def NLLBG(coord): ''' Returns the Negative Log Likelihood (NLL) for a taken coordinate (coord) value from a PDF evaluated with a fixed set of t,sigma data (see "from data import...") and the arg (coord) value. Args: coord: A 2D array/list containing the floating point tau and a(ratio of the particle to background signal) value in the format [tau,a] or np.array([tau,a]) Returns: NLL: The value of the NLL computed from the (t,sigma) dataset and input coord argument Example:>>> NLLBG([0.404,1.0]) 6220.45362533 ''' #Unzip the coordinate list/array into the tau and a component tau, a = coord #Log Likelihood LL = 0. for i in range(0, len(t)): #Calculate the PDF for each t,sigma value and the tau and a value P = a * fitSig(t[i], sigma[i], tau) + (1 - a) * fitBG(t[i], sigma[i]) logP = np.log(P) #Sum all the negative log P to give the LL (positive log likelihood) LL += logP NLL = -LL return NLL
def NLL2500(coord): ''' Returns the Negative Log Likelihood (NLL) for a taken tau (coord) value from a PDF evaluated with only the first 2500 data from a fixed set of t,sigma data (see "from data import...") and the arg (coord) value. ''' tau = coord[0] #Likelihood LL = 0. for i in range(0, len(t[:2500])): #Calculate the PDF for each t,sigma value and the tau value P = fitSig(t[i], sigma[i], tau) #Convert the evaluated PDF for each (t,sigma) measurement into natural log form logP = np.log(P) #Sum all the negative log P to give the LL (positive log likelihood) LL += logP NLL = -LL return NLL