use of edu.cmu.tetrad.bayes.StoredCellProbs in project tetrad by cmu-phil.
the class TestCellProbabilities method testCreateUsingBayesIm.
@Test
public void testCreateUsingBayesIm() {
RandomUtil.getInstance().setSeed(4828385834L);
Graph graph = GraphConverter.convert("X1-->X2,X1-->X3,X2-->X4,X3-->X4");
Dag dag = new Dag(graph);
BayesPm bayesPm = new BayesPm(dag);
BayesIm bayesIm = new MlBayesIm(bayesPm, MlBayesIm.RANDOM);
StoredCellProbs cellProbs = StoredCellProbs.createCellTable(bayesIm);
double prob = cellProbs.getCellProb(new int[] { 0, 0, 0, 0 });
assertEquals(0.0058, prob, 0.0001);
}
use of edu.cmu.tetrad.bayes.StoredCellProbs in project tetrad by cmu-phil.
the class TestCellProbabilities method testCreateRandom.
@Test
public void testCreateRandom() {
RandomUtil.getInstance().setSeed(4828385834L);
DiscreteVariable x = new DiscreteVariable("X", 3);
DiscreteVariable y = new DiscreteVariable("Y", 3);
DiscreteVariable z = new DiscreteVariable("Z", 3);
DiscreteVariable w = new DiscreteVariable("W", 2);
List<Node> variables = new LinkedList<>();
variables.add(x);
variables.add(y);
variables.add(z);
variables.add(w);
StoredCellProbs cellProbabilities = StoredCellProbs.createRandomCellTable(variables);
double prob = cellProbabilities.getCellProb(new int[] { 0, 0, 0, 0 });
assertEquals(0.002, prob, 0.0001);
}
Aggregations