use of edu.cmu.tetrad.bayes.BayesIm in project tetrad by cmu-phil.
the class TestProposition method sampleBayesIm2.
private BayesIm sampleBayesIm2() {
Node a = new GraphNode("a");
Node b = new GraphNode("b");
Node c = new GraphNode("c");
Dag graph;
graph = new Dag();
graph.addNode(a);
graph.addNode(b);
graph.addNode(c);
graph.addDirectedEdge(a, b);
graph.addDirectedEdge(a, c);
graph.addDirectedEdge(b, c);
BayesPm bayesPm = new BayesPm(graph);
bayesPm.setNumCategories(b, 3);
BayesIm bayesIm1 = new MlBayesIm(bayesPm);
bayesIm1.setProbability(0, 0, 0, .3);
bayesIm1.setProbability(0, 0, 1, .7);
bayesIm1.setProbability(1, 0, 0, .3);
bayesIm1.setProbability(1, 0, 1, .4);
bayesIm1.setProbability(1, 0, 2, .3);
bayesIm1.setProbability(1, 1, 0, .6);
bayesIm1.setProbability(1, 1, 1, .1);
bayesIm1.setProbability(1, 1, 2, .3);
bayesIm1.setProbability(2, 0, 0, .9);
bayesIm1.setProbability(2, 0, 1, .1);
bayesIm1.setProbability(2, 1, 0, .1);
bayesIm1.setProbability(2, 1, 1, .9);
bayesIm1.setProbability(2, 2, 0, .5);
bayesIm1.setProbability(2, 2, 1, .5);
bayesIm1.setProbability(2, 3, 0, .2);
bayesIm1.setProbability(2, 3, 1, .8);
bayesIm1.setProbability(2, 4, 0, .6);
bayesIm1.setProbability(2, 4, 1, .4);
bayesIm1.setProbability(2, 5, 0, .7);
bayesIm1.setProbability(2, 5, 1, .3);
return bayesIm1;
}
use of edu.cmu.tetrad.bayes.BayesIm in project tetrad by cmu-phil.
the class UpdaterEditingTableModelObs method addListOfEvidence.
private void addListOfEvidence(Box verticalBox) {
boolean foundACondition = false;
for (int i = 0; i < evidence.getNumNodes(); i++) {
if (evidence.hasNoEvidence(i)) {
continue;
}
foundACondition = true;
Node node = evidence.getNode(i);
Box c = Box.createHorizontalBox();
c.add(Box.createRigidArea(new Dimension(30, 1)));
StringBuilder buf = new StringBuilder();
buf.append("<html>").append(node.getName()).append(" = ");
boolean listedOneAlready = false;
for (int j = 0; j < evidence.getNumCategories(i); j++) {
if (evidence.getProposition().isAllowed(i, j)) {
if (listedOneAlready) {
buf.append(" <i>OR</i> ");
}
BayesIm manipulatedBayesIm = updaterWrapper.getBayesUpdater().getManipulatedBayesIm();
String valueName = manipulatedBayesIm.getBayesPm().getCategory(node, j);
buf.append(valueName);
listedOneAlready = true;
}
}
buf.append("</html>");
c.add(new JLabel(buf.toString()));
c.add(Box.createHorizontalGlue());
verticalBox.add(c);
}
if (!foundACondition) {
Box e = Box.createHorizontalBox();
e.add(Box.createRigidArea(new Dimension(30, 1)));
e.add(new JLabel("--No Evidence--"));
e.add(Box.createHorizontalGlue());
verticalBox.add(e);
}
}
use of edu.cmu.tetrad.bayes.BayesIm in project tetrad by cmu-phil.
the class UpdaterEditingTableModelObs method getNumParents.
private int getNumParents() {
UpdaterEditingTableModelObs editingTableModel = (UpdaterEditingTableModelObs) getModel();
BayesIm bayesIm = editingTableModel.getBayesIm();
int nodeIndex = editingTableModel.getNodeIndex();
return bayesIm.getNumParents(nodeIndex);
}
use of edu.cmu.tetrad.bayes.BayesIm in project tetrad by cmu-phil.
the class UpdaterEditingTableModel method addListOfEvidence.
private void addListOfEvidence(Box verticalBox) {
boolean foundACondition = false;
for (int i = 0; i < evidence.getNumNodes(); i++) {
if (evidence.hasNoEvidence(i)) {
continue;
}
foundACondition = true;
Node node = evidence.getNode(i);
Box c = Box.createHorizontalBox();
c.add(Box.createRigidArea(new Dimension(30, 1)));
StringBuilder buf = new StringBuilder();
buf.append("<html>").append(node.getName()).append(" = ");
boolean listedOneAlready = false;
for (int j = 0; j < evidence.getNumCategories(i); j++) {
if (evidence.getProposition().isAllowed(i, j)) {
if (listedOneAlready) {
buf.append(" <i>OR</i> ");
}
BayesIm manipulatedBayesIm = updaterWrapper.getBayesUpdater().getManipulatedBayesIm();
String valueName = manipulatedBayesIm.getBayesPm().getCategory(node, j);
buf.append(valueName);
listedOneAlready = true;
}
}
buf.append("</html>");
c.add(new JLabel(buf.toString()));
c.add(Box.createHorizontalGlue());
verticalBox.add(c);
}
if (!foundACondition) {
Box e = Box.createHorizontalBox();
e.add(Box.createRigidArea(new Dimension(30, 1)));
e.add(new JLabel("--No Evidence--"));
e.add(Box.createHorizontalGlue());
verticalBox.add(e);
}
}
use of edu.cmu.tetrad.bayes.BayesIm in project tetrad by cmu-phil.
the class UpdaterEditingTableModel method getNumParents.
private int getNumParents() {
UpdaterEditingTableModel editingTableModel = (UpdaterEditingTableModel) getModel();
BayesIm bayesIm = editingTableModel.getBayesIm();
int nodeIndex = editingTableModel.getNodeIndex();
return bayesIm.getNumParents(nodeIndex);
}
Aggregations