Esempio n. 1
0
 def test_process_graph_1_factor(self):
     """
     Test that the get_posterior_joint returns the correct joint distribution (after the graph has been processed)
     for a graph constructed with a single factor.
     """
     factors = [self.p_a_b_c]
     cga = ClusterGraph(factors)
     cga.process_graph()
     actual_posterior_joint = cga.get_posterior_joint()
     expected_posterior_joint = self.p_a_b_c.copy()
     self.assertTrue(
         actual_posterior_joint.equals(expected_posterior_joint))
Esempio n. 2
0
 def test_process_graph_1_factor_se(self):
     """
     Test that the get_posterior_joint returns the correct joint distribution (after the graph has been processed)
     for a graph constructed with a single factor and special evidence.
     """
     factors = [self.p_a_b_c]
     cga = ClusterGraph(factors, special_evidence={"a": 0.3})
     cga.process_graph()
     actual_posterior_joint = cga.get_posterior_joint()
     expected_posterior_joint = self.p_a_b_c.observe(["a"], [0.3])
     self.assertTrue(
         actual_posterior_joint.equals(expected_posterior_joint))
Esempio n. 3
0
 def test_get_posterior_joint(self):
     """
     Test that the get_posterior_joint returns the correct joint distribution after the graph has been processed.
     """
     factors = [self.p_a, self.p_b_g_a, self.p_c_g_a]
     cga = ClusterGraph(factors)
     cga.process_graph()
     actual_posterior_joint = cga.get_posterior_joint()
     actual_posterior_joint._update_covform()
     expected_posterior_joint = self.p_a_b_c.copy()
     self.assertTrue(
         actual_posterior_joint.equals(expected_posterior_joint))