Exemple #1
0
 def test_impossible_update_covform(self):
     """
     Test that the _update_covform raises a LinAlgError when the precision matrix is not invertible.
     """
     gaussian = Gaussian(prec=np.zeros([2, 2]),
                         h_vec=[0.0, 0.0],
                         g_val=0.0,
                         var_names=["a", "b"])
     with self.assertRaises(Exception):
         gaussian._update_covform()
Exemple #2
0
    def test_log_potential_different_forms(self):
        """
        Test that the log_potential function returns the same value, regardless of the parameter form.
        """
        gaussian = Gaussian(prec=[[7.0, 2.0], [2.0, 6.0]],
                            h_vec=[4.0, 3.0],
                            g_val=0.0,
                            var_names=["a", "b"])

        x_val = [7, 3]
        vrs = ["a", "b"]
        log_pot_canform = gaussian.log_potential(x_val=x_val, vrs=vrs)
        gaussian._update_covform()
        gaussian.canform = False
        log_pot_covform = gaussian.log_potential(x_val=x_val, vrs=vrs)
        self.assertAlmostEqual(log_pot_canform, log_pot_covform, places=1)