Example #1
0
 def test_gamma_snooker_choice(self):
     """Test that when a snooker move is made, gamma is set to a random value between 1.2 and 2.2."""
     self.param, self.like = onedmodel()
     model = Model(likelihood=self.like, sampled_parameters=self.param)
     step = Dream(model=model)
     self.assertGreaterEqual(step.set_gamma(DEpairs=1, snooker_choice=True, gamma_level_choice=1, d_prime=3), 1.2)
     self.assertLess(step.set_gamma(DEpairs=1, snooker_choice=True, gamma_level_choice=1, d_prime=3), 2.2)
Example #2
0
 def test_gamma_array(self):
     """Test assigned value of gamma array matches for test data."""
     true_gamma_array = np.array([[1.683, 1.19, .972, .841, .753]])
     self.param, self.like = onedmodel()
     model = Model(likelihood=self.like, sampled_parameters=self.param)
     dream = Dream(model=model, DEpairs=5, p_gamma_unity=0)
     for d_prime in range(1, dream.total_var_dimension+1):
         for n_DEpair in range(1, 6):
             self.assertAlmostEqual(true_gamma_array[d_prime-1][n_DEpair-1], dream.set_gamma(DEpairs=n_DEpair, snooker_choice=False, gamma_level_choice=1, d_prime=d_prime), places=3)
Example #3
0
 def test_gamma_unityfraction(self):
     """Test that gamma value is set to 1 the fraction of times indicated by the p_gamma_unity DREAM parameter."""
     self.param, self.like = onedmodel()
     n_unity_choices = 0
     model = Model(likelihood=self.like, sampled_parameters=self.param)
     step = Dream(model=model)
     fraction = step.p_gamma_unity
     for iteration in range(10000):
        choice = step.set_gamma(DEpairs=1, snooker_choice=False, gamma_level_choice=1, d_prime=step.total_var_dimension)
        if choice == 1:
            n_unity_choices += 1
     emp_frac = n_unity_choices/10000.0
     self.assertAlmostEqual(emp_frac, fraction, places=1)