use of edu.cmu.tetrad.data.DiscreteVariable 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);
}
use of edu.cmu.tetrad.data.DiscreteVariable in project tetrad by cmu-phil.
the class TestColtDataSet method testMixed.
@Test
public void testMixed() {
List<Node> variables = new LinkedList<>();
DiscreteVariable x1 = new DiscreteVariable("X1");
variables.add(x1);
ContinuousVariable x2 = new ContinuousVariable("X2");
variables.add(x2);
DataSet dataSet = new ColtDataSet(5, variables);
assertTrue(dataSet.getVariables().get(0) instanceof DiscreteVariable);
assertTrue(dataSet.getVariables().get(1) instanceof ContinuousVariable);
assertTrue(dataSet.getInt(0, 0) == -99);
assertTrue(Double.isNaN(dataSet.getDouble(1, 0)));
}
use of edu.cmu.tetrad.data.DiscreteVariable in project tetrad by cmu-phil.
the class TestCellTable method setUp.
public final void setUp() {
this.table = new CellTable(dims);
// // Add data to table.
List<Node> variables = new LinkedList<>();
variables.add(new DiscreteVariable("X1", 2));
variables.add(new DiscreteVariable("X2", 2));
variables.add(new DiscreteVariable("X3", 2));
variables.add(new DiscreteVariable("X4", 2));
DataSet dataSet = new ColtDataSet(data.length, variables);
for (int i = 0; i < data.length; i++) {
for (int j = 0; j < data[0].length; j++) {
dataSet.setInt(i, j, data[i][j]);
}
}
int[] indices = new int[] { 0, 1, 2, 3 };
this.table.addToTable(dataSet, indices);
}
use of edu.cmu.tetrad.data.DiscreteVariable in project tetrad by cmu-phil.
the class TestColtDataSet method testDiscreteFromScratch.
@Test
public void testDiscreteFromScratch() {
DataSet dataSet = new ColtDataSet(0, Collections.EMPTY_LIST);
DiscreteVariable x1 = new DiscreteVariable("X1");
dataSet.addVariable(x1);
dataSet.setInt(0, 0, 0);
dataSet.setInt(1, 0, 2);
dataSet.setInt(2, 0, 1);
DiscreteVariable x2 = new DiscreteVariable("X2");
dataSet.addVariable(x2);
dataSet.setInt(0, 1, 0);
dataSet.setInt(1, 1, 2);
dataSet.setInt(2, 1, 1);
ColtDataSet _dataSet = new ColtDataSet((ColtDataSet) dataSet);
assertEquals(dataSet, _dataSet);
assertEquals(dataSet.getInt(1, 1), 2);
}
use of edu.cmu.tetrad.data.DiscreteVariable in project tetrad by cmu-phil.
the class TestDiscreteProbs method testCreateRandom.
public static void testCreateRandom() {
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);
}
Aggregations