@Test public void test() throws Exception { VMPExample.main(null); }
public static void main(String[] args) throws Exception { BayesianNetwork bn = BayesianNetworkLoader.loadFromFile("./networks/simulated/WasteIncinerator.bn"); Variable varMout = bn.getVariables().getVariableByName("Mout"); Variable varW = bn.getVariables().getVariableByName("W"); InferenceAlgorithm inferenceAlgorithm = new VMP(); inferenceAlgorithm.setModel(bn); Assignment assignment = new HashMapAssignment(1); assignment.setValue(varW,0); inferenceAlgorithm.setEvidence(assignment); inferenceAlgorithm.runInference(); System.out.println("P(Mout|W=0) = " + inferenceAlgorithm.getPosterior(varMout)); System.out.println("P(0.7<Mout<6.59 | W=0) = " + inferenceAlgorithm.getExpectedValue(varMout, v -> (0.7 < v && v < 6.59) ? 1.0 : 0.0 )); System.out.println("P(W=0) = "+Math.exp(inferenceAlgorithm.getLogProbabilityOfEvidence())); }
VMPExample { public static void main(String[] args) throws Exception { BayesianNetwork bn = BayesianNetworkLoader.loadFromFile("./networks/simulated/WasteIncinerator.bn"); Variable varMout = bn.getVariables().getVariableByName("Mout"); Variable varW = bn.getVariables().getVariableByName("W"); InferenceAlgorithm inferenceAlgorithm = new VMP(); inferenceAlgorithm.setModel(bn); Assignment assignment = new HashMapAssignment(1); assignment.setValue(varW,0); inferenceAlgorithm.setEvidence(assignment); inferenceAlgorithm.runInference(); System.out.println("P(Mout|W=0) = " + inferenceAlgorithm.getPosterior(varMout)); System.out.println("P(0.7<Mout<6.59 | W=0) = " + inferenceAlgorithm.getExpectedValue(varMout, v -> (0.7 < v && v < 6.59) ? 1.0 : 0.0 )); System.out.println("P(W=0) = "+Math.exp(inferenceAlgorithm.getLogProbabilityOfEvidence())); } }
VMPExample { public static void main(String[] args) throws Exception { BayesianNetwork bn = BayesianNetworkLoader.loadFromFile("./networks/simulated/WasteIncinerator.bn"); Variable varMout = bn.getVariables().getVariableByName("Mout"); Variable varW = bn.getVariables().getVariableByName("W"); InferenceAlgorithm inferenceAlgorithm = new VMP(); inferenceAlgorithm.setModel(bn); Assignment assignment = new HashMapAssignment(1); assignment.setValue(varW,0); inferenceAlgorithm.setEvidence(assignment); inferenceAlgorithm.runInference(); System.out.println("P(Mout|W=0) = " + inferenceAlgorithm.getPosterior(varMout)); System.out.println("P(0.7<Mout<6.59 | W=0) = " + inferenceAlgorithm.getExpectedValue(varMout, v -> (0.7 < v && v < 6.59) ? 1.0 : 0.0 )); System.out.println("P(W=0) = "+Math.exp(inferenceAlgorithm.getLogProbabilityOfEvidence())); }  }
VMPExample { public static void main(String[] args) throws Exception { BayesianNetwork bn = BayesianNetworkLoader.loadFromFile("./networks/simulated/WasteIncinerator.bn"); Variable varMout = bn.getVariables().getVariableByName("Mout"); Variable varW = bn.getVariables().getVariableByName("W"); InferenceAlgorithm inferenceAlgorithm = new VMP(); inferenceAlgorithm.setModel(bn); Assignment assignment = new HashMapAssignment(1); assignment.setValue(varW,0); inferenceAlgorithm.setEvidence(assignment); inferenceAlgorithm.runInference(); System.out.println("P(Mout|W=0) = " + inferenceAlgorithm.getPosterior(varMout)); System.out.println("P(0.7<Mout<6.59 | W=0) = " + inferenceAlgorithm.getExpectedValue(varMout, v -> (0.7 < v && v < 6.59) ? 1.0 : 0.0 )); System.out.println("P(W=0) = "+Math.exp(inferenceAlgorithm.getLogProbabilityOfEvidence())); }  static void main(String[] args); }
VMPExample { public static void main(String[] args) throws Exception { BayesianNetwork bn = BayesianNetworkLoader.loadFromFile("./networks/simulated/WasteIncinerator.bn"); Variable varMout = bn.getVariables().getVariableByName("Mout"); Variable varW = bn.getVariables().getVariableByName("W"); InferenceAlgorithm inferenceAlgorithm = new VMP(); inferenceAlgorithm.setModel(bn); Assignment assignment = new HashMapAssignment(1); assignment.setValue(varW,0); inferenceAlgorithm.setEvidence(assignment); inferenceAlgorithm.runInference(); System.out.println("P(Mout|W=0) = " + inferenceAlgorithm.getPosterior(varMout)); System.out.println("P(0.7<Mout<6.59 | W=0) = " + inferenceAlgorithm.getExpectedValue(varMout, v -> (0.7 < v && v < 6.59) ? 1.0 : 0.0 )); System.out.println("P(W=0) = "+Math.exp(inferenceAlgorithm.getLogProbabilityOfEvidence())); }  static void main(String[] args);  }