From 4521e01bd9e6dde09aa1f3ccb4300a47e875c2c1 Mon Sep 17 00:00:00 2001 From: tlatorre Date: Fri, 9 Oct 2020 11:31:25 -0500 Subject: don't run nlopt before running MCMC This commit updates the chi2 script to skip minimzing the likelihood before running the MCMC. The reason for this is that I was occasionally seeing a linear algebra error about a singular matrix when running the MCMC with the KDEMove which I suspect is caused by too many points being in the same place. --- utils/chi2 | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) (limited to 'utils/chi2') diff --git a/utils/chi2 b/utils/chi2 index 9835ba3..30a0fbe 100755 --- a/utils/chi2 +++ b/utils/chi2 @@ -366,23 +366,9 @@ def do_fit(data,muon,data_mc,bins,steps,print_nll=False,walkers=100,thin=10): """ nll = make_nll(data,muon,data_mc,bins,print_nll) - x0 = np.array(PRIORS) - opt = nlopt.opt(nlopt.LN_SBPLX, len(x0)) - opt.set_min_objective(nll) - low = np.array(PRIORS_LOW) - high = np.array(PRIORS_HIGH) - opt.set_lower_bounds(low) - opt.set_upper_bounds(high) - opt.set_ftol_abs(1e-2) - opt.set_initial_step([0.01]*len(x0)) - - pos = np.empty((walkers, len(x0)),dtype=np.double) + pos = np.empty((walkers, len(PRIORS)),dtype=np.double) for i in range(pos.shape[0]): pos[i] = truncnorm_scaled(PRIORS_LOW,PRIORS_HIGH,PRIORS,PRIOR_UNCERTAINTIES) - pos[i,:] = np.clip(pos[i,:],low,high) - pos[i] = opt.optimize(pos[i]) - with printoptions(precision=2, suppress=True): - print("pos[%i] = %s, nll = %.2f" % (i, pos[i], opt.last_optimum_value())) nwalkers, ndim = pos.shape -- cgit