Skip to content

Commit e59b3af

Browse files
committed
Add second test
1 parent 2d58a5b commit e59b3af

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

gtsam/hybrid/tests/testGaussianMixtureFactor.cpp

+20-3
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ TEST(GaussianMixtureFactor, TwoStateModel2) {
555555
using namespace test_two_state_estimation;
556556

557557
double mu0 = 1.0, mu1 = 3.0;
558-
double sigma0 = 6.0, sigma1 = 4.0;
558+
double sigma0 = 0.5, sigma1 = 2.0;
559559
auto hybridMotionModel = CreateHybridMotionModel(mu0, mu1, sigma0, sigma1);
560560

561561
// Start with no measurement on x1, only on x0
@@ -605,7 +605,7 @@ TEST(GaussianMixtureFactor, TwoStateModel2) {
605605
// Now we add a measurement z1 on x1
606606
HybridBayesNet hbn = CreateBayesNet(hybridMotionModel, true);
607607

608-
double z1 = 2.2;
608+
double z1 = 4.0; // favors m==1
609609
given.insert(Z(1), Vector1(z1));
610610

611611
HybridGaussianFactorGraph gfg = hbn.toFactorGraph(given);
@@ -636,7 +636,24 @@ TEST(GaussianMixtureFactor, TwoStateModel2) {
636636
// Since we have a measurement on z2, we get a definite result
637637
// Values taken from an importance sampling run with 50k samples:
638638
// approximateDiscreteMarginal(hbn, proposalNet, given);
639-
DiscreteConditional expected(m1, "0.446345/0.553655");
639+
DiscreteConditional expected(m1, "0.481793/0.518207");
640+
EXPECT(assert_equal(expected, *(bn->at(2)->asDiscrete()), 0.01));
641+
}
642+
643+
{
644+
// Add a different measurement z1 on that favors m==0
645+
HybridBayesNet hbn = CreateBayesNet(hybridMotionModel, true);
646+
647+
double z1 = 1.1;
648+
given.insert_or_assign(Z(1), Vector1(z1));
649+
650+
HybridGaussianFactorGraph gfg = hbn.toFactorGraph(given);
651+
HybridBayesNet::shared_ptr bn = gfg.eliminateSequential();
652+
653+
// Since we have a measurement on z2, we get a definite result
654+
// Values taken from an importance sampling run with 50k samples:
655+
// approximateDiscreteMarginal(hbn, proposalNet, given);
656+
DiscreteConditional expected(m1, "0.554485/0.445515");
640657
EXPECT(assert_equal(expected, *(bn->at(2)->asDiscrete()), 0.01));
641658
}
642659
}

0 commit comments

Comments
 (0)