def test_param_mean(self): """Check param_mean estimator.""" self.assertAlmostEqual( e.param_mean(self.ns_run), np.sum(self.w_rel * self.ns_run['theta'][:, 0]), places=12) ndim = self.ns_run['theta'].shape[1] self.assertRaises( IndexError, e.param_mean, self.ns_run, param_ind=ndim) self.assertTrue(np.isnan( e.param_mean(self.ns_run, param_ind=ndim, handle_indexerror=True)))
def test_run_ci_bootstrap(self): """Check bootstrap ci equals estimator expected value when the run only contains one thread.""" run = nestcheck.dummy_data.get_dummy_run(1, 10) ci = nestcheck.error_analysis.run_ci_bootstrap( run, [e.param_mean], n_simulate=10, cred_int=0.5) self.assertAlmostEqual(ci[0], e.param_mean(run), places=12)
def test_dynamic_param(self): """Test numerical results for nested sampling with dynamic_goal=1.""" dynamic_goal = 1 dyPolyChord.run_dypolychord( self.run_func, dynamic_goal, self.settings, init_step=self.ninit, ninit=self.ninit) run = nestcheck.data_processing.process_polychord_run( self.settings['file_root'], self.settings['base_dir']) first_logl = -137.231721859574 if not np.isclose(run['logl'][0], first_logl): warnings.warn( self.random_seed_msg.format(run['logl'][0], first_logl), UserWarning) else: self.assertAlmostEqual(e.param_mean(run), -0.05323120028149568, places=12)
def test_dynamic_evidence(self): """Test numerical results for nested sampling with dynamic_goal=0.""" dynamic_goal = 0 dyPolyChord.run_dypolychord( self.run_func, dynamic_goal, self.settings, init_step=self.ninit, ninit=self.ninit) run = nestcheck.data_processing.process_polychord_run( self.settings['file_root'], self.settings['base_dir']) first_logl = -158.773632799691 if not np.isclose(run['logl'][0], first_logl): warnings.warn( self.random_seed_msg.format(run['logl'][0], first_logl), UserWarning) else: self.assertEqual(e.count_samples(run), 1169) self.assertAlmostEqual(e.param_mean(run), 0.026487985350451874, places=12)
def test_dynamic_both_evidence_and_param(self): """Test numerical results for nested sampling with dynamic_goal=0.25.""" dynamic_goal = 0.25 dyPolyChord.run_dypolychord( self.run_func, dynamic_goal, self.settings, init_step=self.ninit, ninit=self.ninit) run = nestcheck.data_processing.process_polychord_run( self.settings['file_root'], self.settings['base_dir']) first_logl = -165.502617578541 if not np.isclose(run['logl'][0], first_logl): warnings.warn( self.random_seed_msg.format(run['logl'][0], first_logl), UserWarning) else: self.assertEqual(e.count_samples(run), 1093) self.assertAlmostEqual(e.param_mean(run), -0.0021307716191374263, places=12)