Search in sources :

Example 56 with DiscreteVariable

use of edu.cmu.tetrad.data.DiscreteVariable in project tetrad by cmu-phil.

the class TestColtDataSet method testDiscrete.

@Test
public void testDiscrete() {
    int rows = 10;
    int cols = 5;
    List<Node> variables = new LinkedList<>();
    for (int i = 0; i < cols; i++) {
        DiscreteVariable variable = new DiscreteVariable("X" + (i + 1), 3);
        variables.add(variable);
    }
    DataSet dataSet = new ColtDataSet(rows, variables);
    RandomUtil randomUtil = RandomUtil.getInstance();
    for (int i = 0; i < rows; i++) {
        for (int j = 0; j < cols; j++) {
            dataSet.setInt(i, j, randomUtil.nextInt(3));
        }
    }
    ColtDataSet _dataSet = new ColtDataSet((ColtDataSet) dataSet);
    assertEquals(dataSet, _dataSet);
}
Also used : DiscreteVariable(edu.cmu.tetrad.data.DiscreteVariable) RandomUtil(edu.cmu.tetrad.util.RandomUtil) ColtDataSet(edu.cmu.tetrad.data.ColtDataSet) ColtDataSet(edu.cmu.tetrad.data.ColtDataSet) DataSet(edu.cmu.tetrad.data.DataSet) Node(edu.cmu.tetrad.graph.Node) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Aggregations

DiscreteVariable (edu.cmu.tetrad.data.DiscreteVariable)56 Node (edu.cmu.tetrad.graph.Node)37 DataSet (edu.cmu.tetrad.data.DataSet)18 ContinuousVariable (edu.cmu.tetrad.data.ContinuousVariable)16 ColtDataSet (edu.cmu.tetrad.data.ColtDataSet)11 LinkedList (java.util.LinkedList)9 Test (org.junit.Test)5 ArrayList (java.util.ArrayList)4 Dag (edu.cmu.tetrad.graph.Dag)3 NumberFormat (java.text.NumberFormat)3 Element (nu.xom.Element)3 EdgeListGraph (edu.cmu.tetrad.graph.EdgeListGraph)2 Graph (edu.cmu.tetrad.graph.Graph)2 LogisticRegression (edu.cmu.tetrad.regression.LogisticRegression)2 List (java.util.List)2 Elements (nu.xom.Elements)2 DoubleMatrix2D (cern.colt.matrix.DoubleMatrix2D)1 TakesInitialGraph (edu.cmu.tetrad.algcomparison.utils.TakesInitialGraph)1 StoredCellProbs (edu.cmu.tetrad.bayes.StoredCellProbs)1 BoxDataSet (edu.cmu.tetrad.data.BoxDataSet)1