Credal InferenceΒΆ

Crema provides exact and approximate inference algorithms over credal networks. For the exact one, create an object of class CredalVariableElimination and run the query. The result is an object of class VertexFactor.

// set up the inference and run the queries
CredalVariableElimination inf = new CredalVariableElimination();
VertexFactor res1 = inf.query(cnet, ObservationBuilder.observe(X0, 0), X1);
VertexFactor res2 = inf.query(cnet, X0);

Approximate inference can be done by means of linear programming. For this, create the an object of class CredalApproxLP and then run the query. Note that the output is an IntervalFactor.

// set up the inference and run the queries
CredalApproxLP<SeparateHalfspaceFactor> inf = new CredalApproxLP<>();
IntervalFactor res1 = inf.query(cnet, ObservationBuilder.observe(X0, 0), X1);
IntervalFactor res2 = inf.query(cnet, X1);

double[] lbound = res1.getLower();
double[] ubound = res1.getUpper();