def analysis(self, _posterior): """Create an eos.Analysis object for the named posterior.""" if _posterior not in self._posteriors: raise RuntimeError( 'Cannot create analysis for unknown posterior: \'{}\''.format( _posterior)) posterior = self._posteriors[_posterior] prior = [] for p in posterior['prior']: prior.extend(self._priors[p]['parameters']) likelihood = [] manual_constraints = {} for lh in posterior['likelihood']: likelihood.extend(self._likelihoods[lh]['constraints'] if 'constraints' in self._likelihoods[lh] else []) manual_constraints.update( self._likelihoods[lh]['manual_constraints'] if 'manual_constraints' in self._likelihoods[lh] else {}) global_options = posterior[ 'global_options'] if 'global_options' in posterior else None return eos.Analysis(prior, likelihood, global_options, manual_constraints=manual_constraints)
def analysis(self, _posterior): """Create an eos.Analysis object for the named posterior.""" if _posterior not in self._posteriors: raise RuntimeError( 'Cannot create analysis for unknown posterior: \'{}\''.format( _posterior)) posterior = self._posteriors[_posterior] prior = [] for p in posterior['prior']: prior.extend(self._priors[p]['parameters']) likelihood = [] manual_constraints = {} for lh in posterior['likelihood']: LH_ALLOWED_KEYS = {'name', 'constraints', 'manual_constraints'} for key in self._likelihoods[lh]: if key not in LH_ALLOWED_KEYS: raise KeyError( f"Unsupported key in 'likelihoods['{lh}']': {key}") if 'constraints' not in self._likelihoods[ lh] and 'manual_constraints' not in self._likelihoods[lh]: raise KeyError( f'Missing entry in \'likelihoods[\'{lh}\']\': neither \'constraints\' nor \'manual_constraints\' is provided' ) likelihood.extend(self._likelihoods[lh]['constraints'] if 'constraints' in self._likelihoods[lh] else []) manual_constraints.update( self._likelihoods[lh]['manual_constraints'] if 'manual_constraints' in self._likelihoods[lh] else {}) global_options = posterior[ 'global_options'] if 'global_options' in posterior else {} fixed_parameters = posterior[ 'fixed_parameters'] if 'fixed_parameters' in posterior else {} return eos.Analysis(prior, likelihood, global_options, manual_constraints=manual_constraints, fixed_parameters=fixed_parameters)
def clone(self): """Returns an independent instance of eos.Analysis.""" return eos.Analysis(**self.init_args)
def test_parameter_scaling(self): analysis_args = { 'global_options': { 'form-factors': 'BSZ2015', 'model': 'CKM' }, 'priors': [{ 'parameter': 'CKM::abs(V_cb)', 'min': 38e-3, 'max': 45e-3, 'type': 'uniform' }, { 'parameter': 'B->D::alpha^f+_0@BSZ2015', 'min': 0.0, 'max': 1.0, 'type': 'uniform' }, { 'parameter': 'B->D::alpha^f+_1@BSZ2015', 'min': -4.0, 'max': -1.0, 'type': 'uniform' }, { 'parameter': 'B->D::alpha^f+_2@BSZ2015', 'min': +4.0, 'max': +6.0, 'type': 'uniform' }, { 'parameter': 'B->D::alpha^f0_1@BSZ2015', 'min': -1.0, 'max': +2.0, 'type': 'uniform' }, { 'parameter': 'B->D::alpha^f0_2@BSZ2015', 'min': -2.0, 'max': 0.0, 'type': 'uniform' }], 'likelihood': [ 'B->D::f_++f_0@HPQCD:2015A', 'B->D::f_++f_0@FNAL+MILC:2015B', 'B^0->D^+e^-nu::BRs@Belle:2015A', 'B^0->D^+mu^-nu::BRs@Belle:2015A' ] } # Test analysis definition analysis = eos.Analysis(**analysis_args) # Test analysis optimization bfp = analysis.optimize() # Test analysis optimization from a random point bfp = analysis.optimize(start_point='random', rng=np.random.mtrand.RandomState(123)) # Test parameter scaling point = bfp.point self.assertTrue(np.max(analysis._par_to_x(point)) < 1.0) self.assertTrue(np.min(analysis._par_to_x(point)) > -1.0) self.assertTrue( np.max(analysis._x_to_par(analysis._par_to_x(point)) - point) < 1e-10)