@Test public void testStorageProbasNoParent() { NodeCategorical nGender = new NodeCategorical(null, "gender"); nGender.addDomain("male", "female"); nGender.setProbabilities(0.55, "male"); nGender.setProbabilities(0.45, "female"); assertEquals(0.55, nGender.getProbability("male"), 1e-5); assertEquals(0.45, nGender.getProbability("female"), 1e-5); assertEquals(0.55, nGender.getConditionalProbability("male"), 1e-5); assertEquals(0.45, nGender.getConditionalProbability("female"), 1e-5); assertTrue("CPT should be valid", nGender.isValid()); }
public boolean isValid() { for (N n: nodes) { if (!n.isValid()) return false; } return true; }
BayesianNetwork { public boolean isValid() { for (N n: nodes) { if (!n.isValid()) return false; } return true; } }
BayesianNetwork { public boolean isValid() { for (N n: nodes) { if (!n.isValid()) return false; } return true; } BayesianNetwork(String name); }
BayesianNetwork { public boolean isValid() { for (N n: nodes) { if (!n.isValid()) return false; } return true; } BayesianNetwork(String name); void add(N n); void addAll(Collection<N> nns); boolean containsNode(N n); N getVariable(String id); void notifyNodesChanged(); List<N> enumerateNodes(); Set<N> getNodes(); void saveAsXMLBIF(File f); void saveAsXMLBIF(String filename); boolean isValid(); Map<N,List<String>> collectInvalidProblems(); Set<N> getAllAncestors(N n); Set<N> getAllChildren(N n); Set<N> getParents(AbstractNode<N> n); Set<N> getChildren(AbstractNode<N> n); }
BayesianNetwork { public boolean isValid() { for (N n: nodes) { if (!n.isValid()) return false; } return true; } BayesianNetwork(String name); void add(N n); void addAll(Collection<N> nns); boolean containsNode(N n); N getVariable(String id); void notifyNodesChanged(); List<N> enumerateNodes(); Set<N> getNodes(); void saveAsXMLBIF(File f); void saveAsXMLBIF(String filename); boolean isValid(); Map<N,List<String>> collectInvalidProblems(); Set<N> getAllAncestors(N n); Set<N> getAllChildren(N n); Set<N> getParents(AbstractNode<N> n); Set<N> getChildren(AbstractNode<N> n);  }