Print estimated marginals and ratios!
parent
7ab4c3e3fb
commit
64831300a5
|
@ -205,9 +205,9 @@ class TestHybridGaussianFactorGraph(GtsamTestCase):
|
||||||
|
|
||||||
# Estimate marginals using importance sampling.
|
# Estimate marginals using importance sampling.
|
||||||
marginals = self.estimate_marginals(bayesNet, sample)
|
marginals = self.estimate_marginals(bayesNet, sample)
|
||||||
# print(f"True mode: {sample.atDiscrete(M(0))}")
|
print(f"True mode: {sample.atDiscrete(M(0))}")
|
||||||
# print(f"P(mode=0; z0, z1) = {marginals[0]}")
|
print(f"P(mode=0; z0, z1) = {marginals[0]}")
|
||||||
# print(f"P(mode=1; z0, z1) = {marginals[1]}")
|
print(f"P(mode=1; z0, z1) = {marginals[1]}")
|
||||||
|
|
||||||
# Check marginals based on sampled mode.
|
# Check marginals based on sampled mode.
|
||||||
if sample.atDiscrete(M(0)) == 0:
|
if sample.atDiscrete(M(0)) == 0:
|
||||||
|
@ -251,8 +251,8 @@ class TestHybridGaussianFactorGraph(GtsamTestCase):
|
||||||
other.insert(measurements)
|
other.insert(measurements)
|
||||||
ratio = self.calculate_ratio(posterior, fg, other)
|
ratio = self.calculate_ratio(posterior, fg, other)
|
||||||
print(f"Ratio: {ratio}\n")
|
print(f"Ratio: {ratio}\n")
|
||||||
# if (ratio > 0):
|
if (ratio > 0):
|
||||||
# self.assertAlmostEqual(ratio, expected_ratio)
|
self.assertAlmostEqual(ratio, expected_ratio)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
Loading…
Reference in New Issue