def nll(data, norm): return atfl.unbinned_nll(model(data), atfl.integral(model(norm)))
def _nll(pars): return atfl.unbinned_nll(data_model(**pars), atfl.integral(norm_model(**pars)))
fit_sample = tft.run_toymc(fit_model, observables_phase_space, 1000000, 1e-20, chunk=1000000) tfr.write_tuple("eff_fit_result.root", fit_sample, observables_data) norm_sample_2 = sqdlz_phsp.rectangular_grid_sample((50, 50)).numpy() norm_sample_2 = np.concatenate( [norm_sample_2, np.array(2500 * [md])[:, np.newaxis]], axis=1) fit = fit_model(norm_sample_2).numpy().reshape((50, 50)) toy_sig = tfr.read_tuple_filtered("test_tuple.root", branches=["mprime", "thetaprime"], sel_branches=["md"], selection="abs(md-1.97)<0.05") hist = np.histogram2d(toy_sig[:, 0], toy_sig[:, 1], bins=(50, 50), range=observables_bounds[:2]) fit = fit / atfl.integral(fit) * atfl.integral(hist[0]) chi2 = np.sum((fit - hist[0])**2 / fit) print(fit) print(hist) print(norm_sample_2) print(f"Chi2={chi2}")
def nll(pars): parslist = [pars[i[0]] for i in parameters_list] return atfl.unbinned_nll(model(data_sample, parslist), atfl.integral(model(norm_sample, parslist)))
def _nll(pars): return atfl.unbinned_nll( fit_model(data, pars), atfl.integral(fit_model(norm, pars)) )