Fix SumFrontals test
parent
b09495376b
commit
4cb03b303b
|
@ -35,7 +35,7 @@ const DiscreteKey mode{M(0), 2};
|
|||
* Create a tiny two variable hybrid model which represents
|
||||
* the generative probability P(z, x, n) = P(z | x, n)P(x)P(n).
|
||||
*/
|
||||
static HybridBayesNet createHybridBayesNet(int num_measurements = 1) {
|
||||
HybridBayesNet createHybridBayesNet(int num_measurements = 1) {
|
||||
// Create hybrid Bayes net.
|
||||
HybridBayesNet bayesNet;
|
||||
|
||||
|
@ -60,8 +60,8 @@ static HybridBayesNet createHybridBayesNet(int num_measurements = 1) {
|
|||
return bayesNet;
|
||||
}
|
||||
|
||||
static HybridGaussianFactorGraph convertBayesNet(const HybridBayesNet& bayesNet,
|
||||
const HybridValues& sample) {
|
||||
HybridGaussianFactorGraph convertBayesNet(const HybridBayesNet& bayesNet,
|
||||
const HybridValues& sample) {
|
||||
HybridGaussianFactorGraph fg;
|
||||
int num_measurements = bayesNet.size() - 2;
|
||||
for (int i = 0; i < num_measurements; i++) {
|
||||
|
@ -74,7 +74,7 @@ static HybridGaussianFactorGraph convertBayesNet(const HybridBayesNet& bayesNet,
|
|||
return fg;
|
||||
}
|
||||
|
||||
static HybridGaussianFactorGraph createHybridGaussianFactorGraph(
|
||||
HybridGaussianFactorGraph createHybridGaussianFactorGraph(
|
||||
int num_measurements = 1) {
|
||||
auto bayesNet = createHybridBayesNet(num_measurements);
|
||||
auto sample = bayesNet.sample();
|
||||
|
|
|
@ -636,10 +636,14 @@ TEST(HybridGaussianFactorGraph, SumFrontals) {
|
|||
// Expected decision tree with two factor graphs:
|
||||
// f(x0;mode=0)P(x0) and f(x0;mode=1)P(x0)
|
||||
GaussianMixture::Sum expected{
|
||||
M(0), GaussianFactorGraph(std::vector<GF>{mixture->factor(d0), prior}),
|
||||
GaussianFactorGraph(std::vector<GF>{mixture->factor(d1), prior})};
|
||||
M(0),
|
||||
{GaussianFactorGraph(std::vector<GF>{mixture->factor(d0), prior}),
|
||||
-0.225791 /* regression */},
|
||||
{GaussianFactorGraph(std::vector<GF>{mixture->factor(d1), prior}),
|
||||
-2.01755 /* regression */}};
|
||||
|
||||
EXPECT(assert_equal(expected(d0), sum(d0)));
|
||||
EXPECT(assert_equal(expected(d0), sum(d0), 1e-5));
|
||||
EXPECT(assert_equal(expected(d1), sum(d1), 1e-5));
|
||||
}
|
||||
|
||||
/* ************************************************************************* */
|
||||
|
|
Loading…
Reference in New Issue