How to use the ultranest.solvecompat.pymultinest_solve_compat function in ultranest

To help you get started, we’ve selected a few ultranest examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github JohannesBuchner / BXA / bxa / xspec / solver.py View on Github external
l = -0.5 * Fit.statistic
			#print("like = %.1f" % l)
			if not numpy.isfinite(l):
				return -1e100
			return l
		
		# run multinest
		if Fit.statMethod.lower() not in BXASolver.allowed_stats:
			raise RuntimeError('ERROR: not using cash (Poisson likelihood) for Poisson data! set Fit.statMethod to cash before analysing (currently: %s)!' % Fit.statMethod)
		
		n_dims = len(self.paramnames)
		resume = kwargs.pop('resume', False)
		Lepsilon = kwargs.pop('Lepsilon', 0.1)

		with XSilence():
			self.results = solve(log_likelihood, self.prior_function, n_dims, 
				paramnames=self.paramnames,
				outputfiles_basename=self.outputfiles_basename, 
				resume=resume, Lepsilon=Lepsilon,
				n_live_points=n_live_points, evidence_tolerance=evidence_tolerance, 
				seed=-1, max_iter=0, wrapped_params=wrapped_params, **kwargs
			)
			self.posterior = self.results['samples']
			chainfilename = '%schain.fits' % self.outputfiles_basename
			store_chain(chainfilename, self.transformations, self.posterior)
			xspec.AllChains.clear()
			xspec.AllChains += chainfilename
		
			# set current parameters to best fit
			self.set_best_fit()
		
		return self.results
github JohannesBuchner / BXA / bxa / sherpa / solver.py View on Github external
#print "%.1f" % l
				return l
			except Exception as e:
				print('Exception in log_likelihood function: ', e)
				for i, p in enumerate(self.parameters):
					print('    Parameter %10s: %f --> %f [%f..%f]' % (p.fullname, p.val, cube[i], p.min, p.max))
				#import sys
				#sys.exit(-127)
				raise Exception("Model evaluation problem") from e
			return -1e300
		
		n_dims = len(self.parameters)
		resume = kwargs.pop('resume', False)
		Lepsilon = kwargs.pop('Lepsilon', 0.1)

		self.results = solve(log_likelihood, prior_transform, n_dims,
			paramnames=self.paramnames,
			outputfiles_basename=self.outputfiles_basename,
			resume=resume, Lepsilon=Lepsilon,
			n_live_points=n_live_points, evidence_tolerance=evidence_tolerance,
			seed=-1, max_iter=0, wrapped_params=wrapped_params, **kwargs
		)
		self.set_best_fit()
		return self.results

ultranest

Fit and compare complex models reliably and rapidly. Advanced Nested Sampling.

GPL-3.0
Latest version published 27 days ago

Package Health Score

76 / 100
Full package analysis

Similar packages