nodes = trueGraph.paths().getAncestors(Collections.singletonList(edge.getNode1()));
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumCompatibleDefiniteDirectedEdgeAncestors.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumCompatibleDefiniteDirectedEdgeAncestors.java
index e882b793a5..e549c0722e 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumCompatibleDefiniteDirectedEdgeAncestors.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumCompatibleDefiniteDirectedEdgeAncestors.java
@@ -2,7 +2,6 @@
import edu.cmu.tetrad.data.DataModel;
import edu.cmu.tetrad.graph.*;
-import edu.cmu.tetrad.search.utils.GraphSearchUtils;
import static edu.cmu.tetrad.graph.GraphUtils.compatible;
@@ -12,7 +11,7 @@
* @author josephramsey
*/
public class NumCompatibleDefiniteDirectedEdgeAncestors implements Statistic {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
@Override
public String getAbbreviation() {
@@ -28,7 +27,7 @@ public String getDescription() {
public double getValue(Graph trueGraph, Graph estGraph, DataModel dataModel) {
GraphUtils.addPagColoring(estGraph);
- Graph pag = GraphSearchUtils.dagToPag(trueGraph);
+ Graph pag = GraphTransforms.dagToPag(trueGraph);
int tp = 0;
int fp = 0;
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumCompatibleDirectedEdgeConfounded.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumCompatibleDirectedEdgeConfounded.java
index dff8657a12..bd5004e6a3 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumCompatibleDirectedEdgeConfounded.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumCompatibleDirectedEdgeConfounded.java
@@ -2,7 +2,6 @@
import edu.cmu.tetrad.data.DataModel;
import edu.cmu.tetrad.graph.*;
-import edu.cmu.tetrad.search.utils.GraphSearchUtils;
import static edu.cmu.tetrad.algcomparison.statistic.LatentCommonAncestorTruePositiveBidirected.existsLatentCommonAncestor;
import static edu.cmu.tetrad.graph.GraphUtils.compatible;
@@ -13,7 +12,7 @@
* @author josephramsey
*/
public class NumCompatibleDirectedEdgeConfounded implements Statistic {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
@Override
public String getAbbreviation() {
@@ -29,7 +28,7 @@ public String getDescription() {
public double getValue(Graph trueGraph, Graph estGraph, DataModel dataModel) {
GraphUtils.addPagColoring(estGraph);
- Graph pag = GraphSearchUtils.dagToPag(trueGraph);
+ Graph pag = GraphTransforms.dagToPag(trueGraph);
int tp = 0;
int fp = 0;
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumCompatibleDirectedEdgeNonAncestors.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumCompatibleDirectedEdgeNonAncestors.java
index a89c8e27f4..1c597b6dcb 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumCompatibleDirectedEdgeNonAncestors.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumCompatibleDirectedEdgeNonAncestors.java
@@ -11,7 +11,7 @@
* @author josephramsey
*/
public class NumCompatibleDirectedEdgeNonAncestors implements Statistic {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
@Override
public String getAbbreviation() {
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumCompatibleEdges.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumCompatibleEdges.java
index caaa289d6c..93edd07325 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumCompatibleEdges.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumCompatibleEdges.java
@@ -3,8 +3,8 @@
import edu.cmu.tetrad.data.DataModel;
import edu.cmu.tetrad.graph.Edge;
import edu.cmu.tetrad.graph.Graph;
+import edu.cmu.tetrad.graph.GraphTransforms;
import edu.cmu.tetrad.graph.GraphUtils;
-import edu.cmu.tetrad.search.utils.GraphSearchUtils;
import static edu.cmu.tetrad.graph.GraphUtils.compatible;
@@ -14,7 +14,7 @@
* @author josephramsey
*/
public class NumCompatibleEdges implements Statistic {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
@Override
public String getAbbreviation() {
@@ -30,7 +30,7 @@ public String getDescription() {
public double getValue(Graph trueGraph, Graph estGraph, DataModel dataModel) {
GraphUtils.addPagColoring(estGraph);
- Graph pag = GraphSearchUtils.dagToPag(trueGraph);
+ Graph pag = GraphTransforms.dagToPag(trueGraph);
int tp = 0;
int fp = 0;
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumCompatiblePossiblyDirectedEdgeAncestors.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumCompatiblePossiblyDirectedEdgeAncestors.java
index 35b0d77c8e..53f6c05db5 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumCompatiblePossiblyDirectedEdgeAncestors.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumCompatiblePossiblyDirectedEdgeAncestors.java
@@ -2,7 +2,6 @@
import edu.cmu.tetrad.data.DataModel;
import edu.cmu.tetrad.graph.*;
-import edu.cmu.tetrad.search.utils.GraphSearchUtils;
import static edu.cmu.tetrad.graph.GraphUtils.compatible;
@@ -12,7 +11,7 @@
* @author josephramsey
*/
public class NumCompatiblePossiblyDirectedEdgeAncestors implements Statistic {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
@Override
public String getAbbreviation() {
@@ -28,7 +27,7 @@ public String getDescription() {
public double getValue(Graph trueGraph, Graph estGraph, DataModel dataModel) {
GraphUtils.addPagColoring(estGraph);
- Graph pag = GraphSearchUtils.dagToPag(trueGraph);
+ Graph pag = GraphTransforms.dagToPag(trueGraph);
int tp = 0;
int fp = 0;
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumCompatiblePossiblyDirectedEdgeNonAncestors.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumCompatiblePossiblyDirectedEdgeNonAncestors.java
index 757094026e..2062f850c6 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumCompatiblePossiblyDirectedEdgeNonAncestors.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumCompatiblePossiblyDirectedEdgeNonAncestors.java
@@ -2,7 +2,6 @@
import edu.cmu.tetrad.data.DataModel;
import edu.cmu.tetrad.graph.*;
-import edu.cmu.tetrad.search.utils.GraphSearchUtils;
import static edu.cmu.tetrad.graph.GraphUtils.compatible;
@@ -12,7 +11,7 @@
* @author josephramsey
*/
public class NumCompatiblePossiblyDirectedEdgeNonAncestors implements Statistic {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
@Override
public String getAbbreviation() {
@@ -28,7 +27,7 @@ public String getDescription() {
public double getValue(Graph trueGraph, Graph estGraph, DataModel dataModel) {
GraphUtils.addPagColoring(estGraph);
- Graph pag = GraphSearchUtils.dagToPag(trueGraph);
+ Graph pag = GraphTransforms.dagToPag(trueGraph);
int tp = 0;
int fp = 0;
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumCompatibleVisibleAncestors.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumCompatibleVisibleAncestors.java
index f07c83e18c..36ae9fa8dc 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumCompatibleVisibleAncestors.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumCompatibleVisibleAncestors.java
@@ -2,7 +2,6 @@
import edu.cmu.tetrad.data.DataModel;
import edu.cmu.tetrad.graph.*;
-import edu.cmu.tetrad.search.utils.GraphSearchUtils;
import static edu.cmu.tetrad.graph.GraphUtils.compatible;
@@ -12,7 +11,7 @@
* @author josephramsey
*/
public class NumCompatibleVisibleAncestors implements Statistic {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
@Override
public String getAbbreviation() {
@@ -28,7 +27,7 @@ public String getDescription() {
public double getValue(Graph trueGraph, Graph estGraph, DataModel dataModel) {
GraphUtils.addPagColoring(estGraph);
- Graph pag = GraphSearchUtils.dagToPag(trueGraph);
+ Graph pag = GraphTransforms.dagToPag(trueGraph);
int tp = 0;
int fp = 0;
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumCompatibleVisibleNonancestors.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumCompatibleVisibleNonancestors.java
index c0cd6b2d69..ecc1dffc80 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumCompatibleVisibleNonancestors.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumCompatibleVisibleNonancestors.java
@@ -1,11 +1,7 @@
package edu.cmu.tetrad.algcomparison.statistic;
import edu.cmu.tetrad.data.DataModel;
-import edu.cmu.tetrad.graph.Edge;
-import edu.cmu.tetrad.graph.Edges;
-import edu.cmu.tetrad.graph.Graph;
-import edu.cmu.tetrad.graph.Node;
-import edu.cmu.tetrad.search.utils.GraphSearchUtils;
+import edu.cmu.tetrad.graph.*;
import static edu.cmu.tetrad.graph.GraphUtils.compatible;
@@ -15,7 +11,7 @@
* @author josephramsey
*/
public class NumCompatibleVisibleNonancestors implements Statistic {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
@Override
public String getAbbreviation() {
@@ -29,7 +25,7 @@ public String getDescription() {
@Override
public double getValue(Graph trueGraph, Graph estGraph, DataModel dataModel) {
- Graph pag = GraphSearchUtils.dagToPag(trueGraph);
+ Graph pag = GraphTransforms.dagToPag(trueGraph);
int tp = 0;
int fp = 0;
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumCorrectDDAncestors.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumCorrectDDAncestors.java
index 62778571be..b3849eab94 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumCorrectDDAncestors.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumCorrectDDAncestors.java
@@ -9,7 +9,7 @@
* @author josephramsey
*/
public class NumCorrectDDAncestors implements Statistic {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
@Override
public String getAbbreviation() {
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumCorrectPDAncestors.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumCorrectPDAncestors.java
index 6722f99f94..e8f55d1ce8 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumCorrectPDAncestors.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumCorrectPDAncestors.java
@@ -9,7 +9,7 @@
* @author josephramsey
*/
public class NumCorrectPDAncestors implements Statistic {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
@Override
public String getAbbreviation() {
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumCorrectVisibleAncestors.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumCorrectVisibleAncestors.java
index 462431fbee..0f64dea0de 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumCorrectVisibleAncestors.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumCorrectVisibleAncestors.java
@@ -9,7 +9,7 @@
* @author josephramsey
*/
public class NumCorrectVisibleAncestors implements Statistic {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
@Override
public String getAbbreviation() {
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumDefinitelyDirected.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumDefinitelyDirected.java
index 18c30bf881..2d7047ec73 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumDefinitelyDirected.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumDefinitelyDirected.java
@@ -1,11 +1,7 @@
package edu.cmu.tetrad.algcomparison.statistic;
import edu.cmu.tetrad.data.DataModel;
-import edu.cmu.tetrad.graph.Edge;
-import edu.cmu.tetrad.graph.Edges;
-import edu.cmu.tetrad.graph.Graph;
-import edu.cmu.tetrad.graph.Node;
-import edu.cmu.tetrad.search.utils.GraphSearchUtils;
+import edu.cmu.tetrad.graph.*;
/**
* The bidirected true positives.
@@ -13,7 +9,7 @@
* @author josephramsey
*/
public class NumDefinitelyDirected implements Statistic {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
@Override
public String getAbbreviation() {
@@ -29,7 +25,7 @@ public String getDescription() {
public double getValue(Graph trueGraph, Graph estGraph, DataModel dataModel) {
int count = 0;
- Graph cpdag = GraphSearchUtils.cpdagForDag(trueGraph);
+ Graph cpdag = GraphTransforms.cpdagForDag(trueGraph);
for (Edge edge : estGraph.getEdges()) {
if (Edges.isDirectedEdge(edge)) {
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumDefinitelyNotDirectedPaths.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumDefinitelyNotDirectedPaths.java
index d90dd0c772..811fdae615 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumDefinitelyNotDirectedPaths.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumDefinitelyNotDirectedPaths.java
@@ -2,7 +2,6 @@
import edu.cmu.tetrad.data.DataModel;
import edu.cmu.tetrad.graph.*;
-import edu.cmu.tetrad.search.utils.GraphSearchUtils;
/**
* The bidirected true positives.
@@ -10,7 +9,7 @@
* @author josephramsey
*/
public class NumDefinitelyNotDirectedPaths implements Statistic {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
@Override
public String getAbbreviation() {
@@ -26,7 +25,7 @@ public String getDescription() {
public double getValue(Graph trueGraph, Graph estGraph, DataModel dataModel) {
int count = 0;
- Graph cpdag = GraphSearchUtils.cpdagForDag(trueGraph);
+ Graph cpdag = GraphTransforms.cpdagForDag(trueGraph);
for (Edge edge : estGraph.getEdges()) {
if (Edges.isDirectedEdge(edge)) {
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumDirectedEdgeAncestors.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumDirectedEdgeAncestors.java
index b922269dea..7b806636c8 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumDirectedEdgeAncestors.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumDirectedEdgeAncestors.java
@@ -12,7 +12,7 @@
* @author josephramsey
*/
public class NumDirectedEdgeAncestors implements Statistic {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
@Override
public String getAbbreviation() {
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumDirectedEdgeBnaMeasuredCounfounded.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumDirectedEdgeBnaMeasuredCounfounded.java
index 22dbdb45c9..571546d787 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumDirectedEdgeBnaMeasuredCounfounded.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumDirectedEdgeBnaMeasuredCounfounded.java
@@ -15,7 +15,7 @@
* @author josephramsey
*/
public class NumDirectedEdgeBnaMeasuredCounfounded implements Statistic {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
@Override
public String getAbbreviation() {
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumDirectedEdgeNoMeasureAncestors.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumDirectedEdgeNoMeasureAncestors.java
index ee48bfc69c..16fb106c22 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumDirectedEdgeNoMeasureAncestors.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumDirectedEdgeNoMeasureAncestors.java
@@ -14,7 +14,7 @@
* @author josephramsey
*/
public class NumDirectedEdgeNoMeasureAncestors implements Statistic {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
@Override
public String getAbbreviation() {
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumDirectedEdgeNotAncNotRev.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumDirectedEdgeNotAncNotRev.java
index 71f44dd1bd..aa575478e1 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumDirectedEdgeNotAncNotRev.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumDirectedEdgeNotAncNotRev.java
@@ -12,7 +12,7 @@
* @author josephramsey
*/
public class NumDirectedEdgeNotAncNotRev implements Statistic {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
@Override
public String getAbbreviation() {
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumDirectedEdgeReversed.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumDirectedEdgeReversed.java
index aa95b60422..3930c61320 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumDirectedEdgeReversed.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumDirectedEdgeReversed.java
@@ -12,7 +12,7 @@
* @author josephramsey
*/
public class NumDirectedEdgeReversed implements Statistic {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
@Override
public String getAbbreviation() {
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumDirectedEdgeVisible.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumDirectedEdgeVisible.java
index f653202e56..82626805c2 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumDirectedEdgeVisible.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumDirectedEdgeVisible.java
@@ -3,13 +3,15 @@
import edu.cmu.tetrad.data.DataModel;
import edu.cmu.tetrad.graph.Edge;
import edu.cmu.tetrad.graph.Graph;
-import edu.cmu.tetrad.search.utils.GraphSearchUtils;
+import edu.cmu.tetrad.graph.GraphTransforms;
/**
+ * Number of X-->Y for which X-->Y visible in true PAG.
+ *
* @author josephramsey
*/
public class NumDirectedEdgeVisible implements Statistic {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
@Override
public String getAbbreviation() {
@@ -25,7 +27,7 @@ public String getDescription() {
public double getValue(Graph trueGraph, Graph estGraph, DataModel dataModel) {
int tp = 0;
- Graph pag = GraphSearchUtils.dagToPag(trueGraph);
+ Graph pag = GraphTransforms.dagToPag(trueGraph);
for (Edge edge : pag.getEdges()) {
if (pag.paths().defVisible(edge)) {
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumDirectedEdges.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumDirectedEdges.java
index 5551988c54..84da8532c2 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumDirectedEdges.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumDirectedEdges.java
@@ -6,10 +6,12 @@
import edu.cmu.tetrad.graph.Graph;
/**
+ * Number of X-->Y in est.
+ *
* @author josephramsey
*/
public class NumDirectedEdges implements Statistic {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
@Override
public String getAbbreviation() {
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumDirectedPathsEst.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumDirectedPathsEst.java
index bca1ea9b5d..313ed944c7 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumDirectedPathsEst.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumDirectedPathsEst.java
@@ -12,7 +12,7 @@
* @author josephramsey
*/
public class NumDirectedPathsEst implements Statistic {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
@Override
public String getAbbreviation() {
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumDirectedPathsTrue.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumDirectedPathsTrue.java
index 218aa463a8..22ff3072aa 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumDirectedPathsTrue.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumDirectedPathsTrue.java
@@ -12,7 +12,7 @@
* @author josephramsey
*/
public class NumDirectedPathsTrue implements Statistic {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
@Override
public String getAbbreviation() {
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumDirectedShouldBePartiallyDirected.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumDirectedShouldBePartiallyDirected.java
index 010133c651..cef32e2cce 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumDirectedShouldBePartiallyDirected.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumDirectedShouldBePartiallyDirected.java
@@ -14,7 +14,7 @@
* @author josephramsey
*/
public class NumDirectedShouldBePartiallyDirected implements Statistic {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
@Override
public String getAbbreviation() {
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumIncorrectDDAncestors.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumIncorrectDDAncestors.java
index 8eb31fd41f..5f514c47c7 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumIncorrectDDAncestors.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumIncorrectDDAncestors.java
@@ -9,7 +9,7 @@
* @author josephramsey
*/
public class NumIncorrectDDAncestors implements Statistic {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
@Override
public String getAbbreviation() {
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumIncorrectPDAncestors.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumIncorrectPDAncestors.java
index caf9e3aa97..9df698dc57 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumIncorrectPDAncestors.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumIncorrectPDAncestors.java
@@ -9,7 +9,7 @@
* @author josephramsey
*/
public class NumIncorrectPDAncestors implements Statistic {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
@Override
public String getAbbreviation() {
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumIncorrectVisibleAncestors.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumIncorrectVisibleAncestors.java
index 75510db7dd..766d097982 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumIncorrectVisibleAncestors.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumIncorrectVisibleAncestors.java
@@ -9,7 +9,7 @@
* @author josephramsey
*/
public class NumIncorrectVisibleAncestors implements Statistic {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
@Override
public String getAbbreviation() {
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumLatentCommonAncestorBidirected.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumLatentCommonAncestorBidirected.java
index 6a9198ea4c..14382fff06 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumLatentCommonAncestorBidirected.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumLatentCommonAncestorBidirected.java
@@ -14,7 +14,7 @@
* @author josephramsey
*/
public class NumLatentCommonAncestorBidirected implements Statistic {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
@Override
public String getAbbreviation() {
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumNondirectedEdges.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumNondirectedEdges.java
index 62d132233d..e40d415ac0 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumNondirectedEdges.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumNondirectedEdges.java
@@ -6,10 +6,12 @@
import edu.cmu.tetrad.graph.Graph;
/**
+ * Number of X---Y in est.
+ *
* @author josephramsey
*/
public class NumNondirectedEdges implements Statistic {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
@Override
public String getAbbreviation() {
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumPartiallyOrientedEdges.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumPartiallyOrientedEdges.java
index 63780c07b2..84b8d1beca 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumPartiallyOrientedEdges.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumPartiallyOrientedEdges.java
@@ -6,10 +6,12 @@
import edu.cmu.tetrad.graph.Graph;
/**
+ * Number of Xo->Y in est.
+ *
* @author josephramsey
*/
public class NumPartiallyOrientedEdges implements Statistic {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
@Override
public String getAbbreviation() {
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumPossiblyDirected.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumPossiblyDirected.java
index 7f302e2eb6..4de8297265 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumPossiblyDirected.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumPossiblyDirected.java
@@ -2,7 +2,6 @@
import edu.cmu.tetrad.data.DataModel;
import edu.cmu.tetrad.graph.*;
-import edu.cmu.tetrad.search.utils.GraphSearchUtils;
/**
* The bidirected true positives.
@@ -10,7 +9,7 @@
* @author josephramsey
*/
public class NumPossiblyDirected implements Statistic {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
@Override
public String getAbbreviation() {
@@ -26,7 +25,7 @@ public String getDescription() {
public double getValue(Graph trueGraph, Graph estGraph, DataModel dataModel) {
int count = 0;
- Graph cpdag = GraphSearchUtils.cpdagForDag(trueGraph);
+ Graph cpdag = GraphTransforms.cpdagForDag(trueGraph);
for (Edge edge : estGraph.getEdges()) {
if (Edges.isDirectedEdge(edge)) {
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumUndirectedEdges.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumUndirectedEdges.java
index fb1f668f9f..2467a8b2e5 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumUndirectedEdges.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumUndirectedEdges.java
@@ -6,10 +6,12 @@
import edu.cmu.tetrad.graph.Graph;
/**
+ * Number of X---Y in est.
+ *
* @author josephramsey
*/
public class NumUndirectedEdges implements Statistic {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
@Override
public String getAbbreviation() {
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumVisibleEst.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumVisibleEst.java
index fc23324264..17cb0b8376 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumVisibleEst.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumVisibleEst.java
@@ -6,10 +6,12 @@
import edu.cmu.tetrad.graph.Graph;
/**
+ * Number of X-->Y visible in est.
+ *
* @author josephramsey
*/
public class NumVisibleEst implements Statistic {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
@Override
public String getAbbreviation() {
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumberOfEdgesEst.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumberOfEdgesEst.java
index e64f42b76b..f641f7cfc6 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumberOfEdgesEst.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumberOfEdgesEst.java
@@ -10,7 +10,7 @@
* @author josephramsey
*/
public class NumberOfEdgesEst implements Statistic {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
@Override
public String getAbbreviation() {
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumberOfEdgesTrue.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumberOfEdgesTrue.java
index 668f2bdc0c..34de9ccb1b 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumberOfEdgesTrue.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/NumberOfEdgesTrue.java
@@ -10,7 +10,7 @@
* @author josephramsey
*/
public class NumberOfEdgesTrue implements Statistic {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
@Override
public String getAbbreviation() {
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/OrientationPrecision.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/OrientationPrecision.java
index 856fc06ff2..d099d9ca3f 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/OrientationPrecision.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/OrientationPrecision.java
@@ -10,7 +10,7 @@
* @author bryanandrews, osephramsey
*/
public class OrientationPrecision implements Statistic {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
@Override
public String getAbbreviation() {
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/OrientationRecall.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/OrientationRecall.java
index b65504aa9a..7065ac60ca 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/OrientationRecall.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/OrientationRecall.java
@@ -10,7 +10,7 @@
* @author bryanandrews, josephramsey
*/
public class OrientationRecall implements Statistic {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
@Override
public String getAbbreviation() {
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/PagAdjacencyPrecision.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/PagAdjacencyPrecision.java
index 9f4dd05ead..fa26169033 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/PagAdjacencyPrecision.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/PagAdjacencyPrecision.java
@@ -3,8 +3,7 @@
import edu.cmu.tetrad.algcomparison.statistic.utils.AdjacencyConfusion;
import edu.cmu.tetrad.data.DataModel;
import edu.cmu.tetrad.graph.Graph;
-
-import static edu.cmu.tetrad.search.utils.GraphSearchUtils.dagToPag;
+import edu.cmu.tetrad.graph.GraphTransforms;
/**
* The adjacency precision. The true positives are the number of adjacencies in both the true and estimated graphs.
@@ -12,7 +11,7 @@
* @author josephramsey
*/
public class PagAdjacencyPrecision implements Statistic {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
@Override
public String getAbbreviation() {
@@ -26,7 +25,7 @@ public String getDescription() {
@Override
public double getValue(Graph trueGraph, Graph estGraph, DataModel dataModel) {
- Graph pag = dagToPag(trueGraph);
+ Graph pag = GraphTransforms.dagToPag(trueGraph);
AdjacencyConfusion adjConfusion = new AdjacencyConfusion(pag, estGraph);
int adjTp = adjConfusion.getTp();
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/PagAdjacencyRecall.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/PagAdjacencyRecall.java
index e858319066..8546ca7628 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/PagAdjacencyRecall.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/PagAdjacencyRecall.java
@@ -3,8 +3,7 @@
import edu.cmu.tetrad.algcomparison.statistic.utils.AdjacencyConfusion;
import edu.cmu.tetrad.data.DataModel;
import edu.cmu.tetrad.graph.Graph;
-
-import static edu.cmu.tetrad.search.utils.GraphSearchUtils.dagToPag;
+import edu.cmu.tetrad.graph.GraphTransforms;
/**
* The adjacency recall. The true positives are the number of adjacencies in both the true and estimated graphs.
@@ -12,7 +11,7 @@
* @author josephramsey
*/
public class PagAdjacencyRecall implements Statistic {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
@Override
public String getAbbreviation() {
@@ -26,7 +25,7 @@ public String getDescription() {
@Override
public double getValue(Graph trueGraph, Graph estGraph, DataModel dataModel) {
- Graph pag = dagToPag(trueGraph);
+ Graph pag = GraphTransforms.dagToPag(trueGraph);
AdjacencyConfusion adjConfusion = new AdjacencyConfusion(pag, estGraph);
int adjTp = adjConfusion.getTp();
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/ParameterColumn.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/ParameterColumn.java
index ea023a76a7..60fe462c45 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/ParameterColumn.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/ParameterColumn.java
@@ -10,7 +10,7 @@
* @author josephramsey
*/
public class ParameterColumn implements Statistic {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
private final String parameter;
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/PercentAmbiguous.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/PercentAmbiguous.java
index 14a91438eb..a1ca55af43 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/PercentAmbiguous.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/PercentAmbiguous.java
@@ -15,7 +15,7 @@
* @author josephramsey
*/
public class PercentAmbiguous implements Statistic {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
@Override
public String getAbbreviation() {
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/PercentBidirectedEdges.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/PercentBidirectedEdges.java
index 0d69fce9b8..bd546ff057 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/PercentBidirectedEdges.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/PercentBidirectedEdges.java
@@ -11,7 +11,7 @@
* @author josephramsey
*/
public class PercentBidirectedEdges implements Statistic {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
@Override
public String getAbbreviation() {
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/ProportionSemidirectedPathsNotReversedEst.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/ProportionSemidirectedPathsNotReversedEst.java
index 2170cd5fa3..ad12c9d59f 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/ProportionSemidirectedPathsNotReversedEst.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/ProportionSemidirectedPathsNotReversedEst.java
@@ -8,10 +8,12 @@
import java.util.List;
/**
+ * Proportion of semi(X, Y) in estimated graph for which there is no semi(Y, X) in true graph.
+ *
* @author josephramsey
*/
public class ProportionSemidirectedPathsNotReversedEst implements Statistic {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
@Override
public String getAbbreviation() {
@@ -35,8 +37,8 @@ public double getValue(Graph trueGraph, Graph estGraph, DataModel dataModel) {
for (Node y : nodes) {
if (x == y) continue;
- if (estGraph.paths().existsSemiDirectedPathFromTo(x, y)) {
- if (!trueGraph.paths().existsSemiDirectedPathFromTo(y, x)) {
+ if (estGraph.paths().existsSemiDirectedPath(x, y)) {
+ if (!trueGraph.paths().existsSemiDirectedPath(y, x)) {
tp++;
} else {
fp++;
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/ProportionSemidirectedPathsNotReversedTrue.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/ProportionSemidirectedPathsNotReversedTrue.java
index d8b8787fd5..4875ba5191 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/ProportionSemidirectedPathsNotReversedTrue.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/ProportionSemidirectedPathsNotReversedTrue.java
@@ -8,10 +8,12 @@
import java.util.List;
/**
+ * Proportion of semi(X, Y) in true graph for which there is no semi(Y, Z) in estimated graph.
+ *
* @author josephramsey
*/
public class ProportionSemidirectedPathsNotReversedTrue implements Statistic {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
@Override
public String getAbbreviation() {
@@ -35,8 +37,8 @@ public double getValue(Graph trueGraph, Graph estGraph, DataModel dataModel) {
for (Node y : nodes) {
if (x == y) continue;
- if (trueGraph.paths().existsSemiDirectedPathFromTo(x, y)) {
- if (!estGraph.paths().existsSemiDirectedPathFromTo(y, x)) {
+ if (trueGraph.paths().existsSemiDirectedPath(x, y)) {
+ if (!estGraph.paths().existsSemiDirectedPath(y, x)) {
tp++;
} else {
fn++;
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/PvalueDistanceToAlpha.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/PvalueDistanceToAlpha.java
index 41570b0f0a..8fef3f87ca 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/PvalueDistanceToAlpha.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/PvalueDistanceToAlpha.java
@@ -16,7 +16,7 @@
* @author josephramsey
*/
public class PvalueDistanceToAlpha implements Statistic {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
private double alpha = 0.01;
public PvalueDistanceToAlpha(double alpha) {
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/PvalueUniformityUnderNull.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/PvalueUniformityUnderNull.java
index c913c7351a..1a23b18e6f 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/PvalueUniformityUnderNull.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/PvalueUniformityUnderNull.java
@@ -14,7 +14,7 @@
* @author josephramsey
*/
public class PvalueUniformityUnderNull implements Statistic {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
private double alpha = 0.01;
public PvalueUniformityUnderNull(double alpha) {
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/SemidirectedPathF1.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/SemidirectedPathF1.java
index 683f7d4290..161c5a1a06 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/SemidirectedPathF1.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/SemidirectedPathF1.java
@@ -13,7 +13,7 @@
* @author Joseh Ramsey
*/
public class SemidirectedPathF1 implements Statistic {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
@Override
public String getAbbreviation() {
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/SemidirectedPrecision.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/SemidirectedPrecision.java
index 7bbecf35cc..fea01ed1aa 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/SemidirectedPrecision.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/SemidirectedPrecision.java
@@ -14,7 +14,7 @@
* @author josephramsey
*/
public class SemidirectedPrecision implements Statistic {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
@Override
public String getAbbreviation() {
@@ -38,8 +38,8 @@ public double getValue(Graph trueGraph, Graph estGraph, DataModel dataModel) {
for (Node y : nodes) {
if (x == y) continue;
- if (estGraph.paths().existsSemiDirectedPathFromTo(x, Collections.singleton(y))) {
- if (trueGraph.paths().existsSemiDirectedPathFromTo(x, Collections.singleton(y))) {
+ if (estGraph.paths().existsSemiDirectedPath(x, Collections.singleton(y))) {
+ if (trueGraph.paths().existsSemiDirectedPath(x, Collections.singleton(y))) {
tp++;
} else {
fp++;
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/SemidirectedRecall.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/SemidirectedRecall.java
index a57c881253..86c91aeb03 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/SemidirectedRecall.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/SemidirectedRecall.java
@@ -14,7 +14,7 @@
* @author josephramsey
*/
public class SemidirectedRecall implements Statistic {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
@Override
public String getAbbreviation() {
@@ -38,8 +38,8 @@ public double getValue(Graph trueGraph, Graph estGraph, DataModel dataModel) {
for (Node y : nodes) {
if (x == y) continue;
- if (trueGraph.paths().existsSemiDirectedPathFromTo(x, Collections.singleton(y))) {
- if (estGraph.paths().existsSemiDirectedPathFromTo(x, Collections.singleton(y))) {
+ if (trueGraph.paths().existsSemiDirectedPath(x, Collections.singleton(y))) {
+ if (estGraph.paths().existsSemiDirectedPath(x, Collections.singleton(y))) {
tp++;
} else {
fn++;
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/Statistic.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/Statistic.java
index 132cf36004..ca79dbfb3c 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/Statistic.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/Statistic.java
@@ -32,6 +32,7 @@ public interface Statistic extends Serializable {
*
* @param trueGraph The true graph (DAG, CPDAG, PAG_of_the_true_DAG).
* @param estGraph The estimated graph (same type).
+ * @param dataModel The data model.
* @return The value of the statistic.
*/
double getValue(Graph trueGraph, Graph estGraph, DataModel dataModel);
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/StructuralHammingDistance.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/StructuralHammingDistance.java
index 29dd119ea2..3a22767caa 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/StructuralHammingDistance.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/StructuralHammingDistance.java
@@ -12,7 +12,7 @@
* @author josephramsey
*/
public class StructuralHammingDistance implements Statistic {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
@Override
public String getAbbreviation() {
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/TailPrecision.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/TailPrecision.java
index 26dccf598f..e072b1bdb5 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/TailPrecision.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/TailPrecision.java
@@ -13,7 +13,7 @@
* @author josephramsey
*/
public class TailPrecision implements Statistic {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
@Override
public String getAbbreviation() {
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/TailRecall.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/TailRecall.java
index 3671e75e12..c365f087d1 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/TailRecall.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/TailRecall.java
@@ -13,7 +13,7 @@
* @author josephramsey
*/
public class TailRecall implements Statistic {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
@Override
public String getAbbreviation() {
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/TrueDagFalseNegativesArrows.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/TrueDagFalseNegativesArrows.java
index 84a63e7dcf..28229a198f 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/TrueDagFalseNegativesArrows.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/TrueDagFalseNegativesArrows.java
@@ -14,7 +14,7 @@
* @author josephramsey
*/
public class TrueDagFalseNegativesArrows implements Statistic {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
@Override
public String getAbbreviation() {
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/TrueDagFalseNegativesTails.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/TrueDagFalseNegativesTails.java
index e7dd509e7a..f0bdbae4a4 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/TrueDagFalseNegativesTails.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/TrueDagFalseNegativesTails.java
@@ -14,7 +14,7 @@
* @author josephramsey
*/
public class TrueDagFalseNegativesTails implements Statistic {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
@Override
public String getAbbreviation() {
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/TrueDagFalsePositiveArrow.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/TrueDagFalsePositiveArrow.java
index 3604306810..9409c853b4 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/TrueDagFalsePositiveArrow.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/TrueDagFalsePositiveArrow.java
@@ -14,7 +14,7 @@
* @author josephramsey
*/
public class TrueDagFalsePositiveArrow implements Statistic {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
@Override
public String getAbbreviation() {
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/TrueDagFalsePositiveTails.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/TrueDagFalsePositiveTails.java
index 07bf4e60e6..fe75064d65 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/TrueDagFalsePositiveTails.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/TrueDagFalsePositiveTails.java
@@ -11,7 +11,7 @@
* @author josephramsey
*/
public class TrueDagFalsePositiveTails implements Statistic {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
@Override
public String getAbbreviation() {
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/TrueDagPrecisionArrow.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/TrueDagPrecisionArrow.java
index ce161ffd78..fee6534567 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/TrueDagPrecisionArrow.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/TrueDagPrecisionArrow.java
@@ -8,10 +8,12 @@
import java.util.List;
/**
+ * The proportion of X*->Y in the estimated graph for which there is no path Y~~>X in the true graph.
+ *
* @author josephramsey
*/
public class TrueDagPrecisionArrow implements Statistic {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
@Override
public String getAbbreviation() {
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/TrueDagPrecisionTails.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/TrueDagPrecisionTails.java
index e33b034f45..b88dda878c 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/TrueDagPrecisionTails.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/TrueDagPrecisionTails.java
@@ -14,7 +14,7 @@
* @author josephramsey
*/
public class TrueDagPrecisionTails implements Statistic {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
@Override
public String getAbbreviation() {
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/TrueDagRecallArrows.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/TrueDagRecallArrows.java
index 5067ed945b..b7cc3c3955 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/TrueDagRecallArrows.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/TrueDagRecallArrows.java
@@ -14,7 +14,7 @@
* @author josephramsey
*/
public class TrueDagRecallArrows implements Statistic {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
@Override
public String getAbbreviation() {
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/TrueDagRecallTails.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/TrueDagRecallTails.java
index 143d17646a..5e75a3ea87 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/TrueDagRecallTails.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/TrueDagRecallTails.java
@@ -14,7 +14,7 @@
* @author josephramsey
*/
public class TrueDagRecallTails implements Statistic {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
@Override
public String getAbbreviation() {
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/TrueDagTruePositiveArrow.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/TrueDagTruePositiveArrow.java
index 3fc37c0359..1367b2bf0b 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/TrueDagTruePositiveArrow.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/TrueDagTruePositiveArrow.java
@@ -11,7 +11,7 @@
* @author josephramsey
*/
public class TrueDagTruePositiveArrow implements Statistic {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
@Override
public String getAbbreviation() {
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/TrueDagTruePositiveDirectedPathNonancestor.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/TrueDagTruePositiveDirectedPathNonancestor.java
index 78639caae4..45b2426f61 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/TrueDagTruePositiveDirectedPathNonancestor.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/TrueDagTruePositiveDirectedPathNonancestor.java
@@ -12,7 +12,7 @@
* @author josephramsey
*/
public class TrueDagTruePositiveDirectedPathNonancestor implements Statistic {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
@Override
public String getAbbreviation() {
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/TrueDagTruePositiveTails.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/TrueDagTruePositiveTails.java
index a4ed824e13..20b75ee93f 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/TrueDagTruePositiveTails.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/TrueDagTruePositiveTails.java
@@ -11,7 +11,7 @@
* @author josephramsey
*/
public class TrueDagTruePositiveTails implements Statistic {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
@Override
public String getAbbreviation() {
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/TwoCycleFalseNegative.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/TwoCycleFalseNegative.java
index b2b0b85bc2..757d3528be 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/TwoCycleFalseNegative.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/TwoCycleFalseNegative.java
@@ -12,7 +12,7 @@
* @author josephramsey, rubens (November 2016)
*/
public class TwoCycleFalseNegative implements Statistic {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
@Override
public String getAbbreviation() {
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/TwoCycleFalsePositive.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/TwoCycleFalsePositive.java
index 7f2e33a3c2..2160872e21 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/TwoCycleFalsePositive.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/TwoCycleFalsePositive.java
@@ -13,7 +13,7 @@
* @author josephramsey, rubens (November 2016)
*/
public class TwoCycleFalsePositive implements Statistic {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
@Override
public String getAbbreviation() {
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/TwoCyclePrecision.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/TwoCyclePrecision.java
index 1dfafb1753..3fa16d163e 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/TwoCyclePrecision.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/TwoCyclePrecision.java
@@ -12,7 +12,7 @@
* @author josephramsey, rubens (November 2016)
*/
public class TwoCyclePrecision implements Statistic {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
@Override
public String getAbbreviation() {
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/TwoCycleRecall.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/TwoCycleRecall.java
index 6d1076d40f..3d2691770b 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/TwoCycleRecall.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/TwoCycleRecall.java
@@ -12,7 +12,7 @@
* @author josephramsey, rubens (November 2016)
*/
public class TwoCycleRecall implements Statistic {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
@Override
public String getAbbreviation() {
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/TwoCycleTruePositive.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/TwoCycleTruePositive.java
index 00b41ed995..43c1d34792 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/TwoCycleTruePositive.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/TwoCycleTruePositive.java
@@ -12,7 +12,7 @@
* @author josephramsey, rubens (November 2016)
*/
public class TwoCycleTruePositive implements Statistic {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
@Override
public String getAbbreviation() {
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/utils/AdjacencyConfusion.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/utils/AdjacencyConfusion.java
index d42a819424..d2833de749 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/utils/AdjacencyConfusion.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/utils/AdjacencyConfusion.java
@@ -18,6 +18,11 @@ public class AdjacencyConfusion {
private int fp;
private int fn;
+ /**
+ * Constructs a new AdjacencyConfusion object from the given graphs.
+ * @param truth The true graph.
+ * @param est The estimated graph.
+ */
public AdjacencyConfusion(Graph truth, Graph est) {
this.tp = 0;
this.fp = 0;
@@ -54,18 +59,34 @@ public AdjacencyConfusion(Graph truth, Graph est) {
this.tn = allEdges - this.fn - this.fp - this.fn;
}
+ /**
+ * Returns the true positive count.
+ * @return the true positive count.
+ */
public int getTp() {
return this.tp;
}
+ /**
+ * Returns the false positive count.
+ * @return the false positive count.
+ */
public int getFp() {
return this.fp;
}
+ /**
+ * Returns the false negative count.
+ * @return the false negative count.
+ */
public int getFn() {
return this.fn;
}
+ /**
+ * Returns the true negative count.
+ * @return the true negative count.
+ */
public int getTn() {
return this.tn;
}
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/utils/ArrowConfusion.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/utils/ArrowConfusion.java
index 32eff0bedc..d09b997733 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/utils/ArrowConfusion.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/utils/ArrowConfusion.java
@@ -30,10 +30,21 @@ public class ArrowConfusion {
private int TCfn;
private int TCfp;
+ /**
+ * Constructs a new ArrowConfusion object.
+ * @param truth the true graph
+ * @param est the estimated graph
+ */
public ArrowConfusion(Graph truth, Graph est) {
this(truth, est, false);
}
+ /**
+ * Constructs a new ArrowConfusion object.
+ * @param truth the true graph
+ * @param est the estimated graph
+ * @param truthAdj if true, use the true graph to determine adjacency for arrowhead FP's
+ */
public ArrowConfusion(Graph truth, Graph est, boolean truthAdj) {
Graph truth1 = truth;
Graph est1 = est;
@@ -259,37 +270,65 @@ public ArrowConfusion(Graph truth, Graph est, boolean truthAdj) {
}
-
+ /**
+ * True positives.
+ * @return the number of true positives
+ */
public int getTp() {
return this.tp;
}
+ /**
+ * False positives.
+ * @return the number of false positives
+ */
public int getFp() {
return this.fp;
}
+ /**
+ * False negatives.
+ * @return the number of false negatives
+ */
public int getFn() {
return this.fn;
}
+ /**
+ * True negatives.
+ * @return the number of true negatives
+ */
public int getTn() {
return this.tn;
}
+ /**
+ * Two positives for two-cycles.
+ * @return the number of true positives for two-cycles.
+ */
public int getTwoCycleTp() {
return this.TCtp;
}
+ /**
+ * False positives for two-cycles.
+ * @return the number of false positives for two-cycles.
+ */
public int getTwoCycleFp() {
return this.TCfp;
}
+ /**
+ * False negatives for two-cycles.
+ * @return the number of false negatives for two-cycles.
+ */
public int getTwoCycleFn() {
return this.TCfn;
}
/**
- * Two positives for common edges.
+ * True positives for common edges.
+ * @return the number of true positives for common edges
*/
public int getTpc() {
return this.tpc;
@@ -297,6 +336,7 @@ public int getTpc() {
/**
* False positives for common edges.
+ * @return the number of false positives for common edges
*/
public int getFpc() {
return this.fpc;
@@ -304,6 +344,7 @@ public int getFpc() {
/**
* False negatives for common edges.
+ * @return the number of false negatives for common edges
*/
public int getFnc() {
return this.fnc;
@@ -311,11 +352,16 @@ public int getFnc() {
/**
* True Negatives for common edges.
+ * @return the number of true negatives for common edges
*/
public int getTnc() {
return this.tnc;
}
+ /**
+ * Returns true if the truth graph is used to determine adjacency for arrowhead FP's.
+ * @return true if the truth graph is used to determine adjacency for arrowhead FP's
+ */
public boolean isTruthAdj() {
return this.truthAdj;
}
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/utils/OrientationConfusion.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/utils/OrientationConfusion.java
index 2e4f2d2dd9..fd81b6baa1 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/utils/OrientationConfusion.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/utils/OrientationConfusion.java
@@ -7,12 +7,6 @@
/**
* A confusion matrix for orientations:
- *
- * True | Estimated | Orientation -------------------------------- a <- b | a <- b | tp, tn | a -> b |
- * fp, fn | a −− b | fn | a .. b | fn -------------------------------- a .. b | a <- b | fp | a ->
- * b | fp | a −− b | | a .. b |
- *
- * The true graph should be a DAG!
*
* @author bryanandrews, josephramsey
*/
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/utils/HasKnowledge.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/utils/HasKnowledge.java
index c6c6f139a8..3c91c06df1 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/utils/HasKnowledge.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/utils/HasKnowledge.java
@@ -10,12 +10,14 @@
public interface HasKnowledge {
/**
+ * Returns a knowledge object.
* @return a knowledge object.
*/
Knowledge getKnowledge();
/**
* Sets a knowledge object.
+ * @param knowledge a knowledge object.
*/
void setKnowledge(Knowledge knowledge);
}
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/utils/HasParameters.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/utils/HasParameters.java
index 6e8ec78863..e12cdf9a6c 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/utils/HasParameters.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/utils/HasParameters.java
@@ -8,6 +8,7 @@
public interface HasParameters {
/**
+ * Returns the list of parameter names that are used. These are looked up in ParamMap, so if they're not
* @return Returns the list of parameter names that are used. These are looked up in ParamMap, so if they're not
* already defined they'll need to be defined there.
*/
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/annotation/AbstractAnnotations.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/annotation/AbstractAnnotations.java
index c88491f25a..2ff0a40347 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/annotation/AbstractAnnotations.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/annotation/AbstractAnnotations.java
@@ -27,6 +27,8 @@
import java.util.stream.Collectors;
/**
+ * Abstract class for annotations.
+ *
* Sep 20, 2017 10:59:43 AM
*
* @param annotation type
@@ -34,8 +36,16 @@
*/
public abstract class AbstractAnnotations {
+ /**
+ * Annotated classes.
+ */
protected final List> annotatedClasses;
+ /**
+ * Constructor.
+ * @param packageName package name
+ * @param type annotation type
+ */
public AbstractAnnotations(String packageName, Class type) {
Reflections reflections = new Reflections(packageName);
Set> classes = reflections.getTypesAnnotatedWith(type);
@@ -45,10 +55,20 @@ public AbstractAnnotations(String packageName, Class type) {
.collect(Collectors.toList());
}
+ /**
+ * Get annotated classes.
+ * @return annotated classes
+ */
public List> getAnnotatedClasses() {
return Collections.unmodifiableList(this.annotatedClasses);
}
+ /**
+ * Filter annotated classes by annotation type.
+ * @param annoClasses annotated classes
+ * @param type annotation type
+ * @return filtered annotated classes
+ */
public List> filterByAnnotation(List> annoClasses, Class extends Annotation> type) {
if (annoClasses == null || type == null) {
return Collections.EMPTY_LIST;
@@ -61,6 +81,12 @@ public List> filterByAnnotation(List> annoCl
return Collections.unmodifiableList(list);
}
+ /**
+ * Filter out annotated classes by annotation type.
+ * @param annoClasses annotated classes
+ * @param type annotation type
+ * @return filtered annotated classes
+ */
public List> filterOutByAnnotation(List> annoClasses, Class extends Annotation> type) {
if (annoClasses == null || type == null) {
return Collections.EMPTY_LIST;
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/annotation/AlgType.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/annotation/AlgType.java
index ff89f7a970..7c71fdcce6 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/annotation/AlgType.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/annotation/AlgType.java
@@ -4,11 +4,34 @@
* Author : Jeremy Espino MD Created 6/30/17 10:36 AM
*/
public enum AlgType {
+
+ /**
+ * If an algorithm forbids latent common causes.
+ */
forbid_latent_common_causes, // PC_All, PcStableMax, FGES, IMaGES_Discrete, IMaGES_Continuous, FANG, EFANG
+
+ /**
+ * If an algorithm allows latent common causes.
+ */
allow_latent_common_causes, // FCI, RFCI, GFCI, SVARFCI, SvarGFCI
- /*DAG, */
+
+ /**
+ * If an algorithm searches for Markov blanekts.
+ */
search_for_Markov_blankets, // FGES-MB, PC-MB
+
+ /**
+ * If an algorithm produces undirected graphs.
+ */
produce_undirected_graphs, // FAS, MGM, GLASSO
+
+ /**
+ * If algorithm orients edges pairwise.
+ */
orient_pairwise, // R3, RSkew, Skew
+
+ /**
+ * If an algorithm searches for structure over latents.
+ */
search_for_structure_over_latents // BPC, FOFC, FTFC
}
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/annotation/Algorithm.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/annotation/Algorithm.java
index 51c797f31b..adc299d00a 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/annotation/Algorithm.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/annotation/Algorithm.java
@@ -32,12 +32,28 @@
@Documented
public @interface Algorithm {
+ /**
+ * Name of the algorithm.
+ * @return name of the algorithm
+ */
String name();
+ /**
+ * Command of the algorithm.
+ * @return command of the algorithm
+ */
String command();
+ /**
+ * Description of the algorithm.
+ * @return description of the algorithm
+ */
AlgType algoType();
+ /**
+ * Description of the algorithm.
+ * @return description of the algorithm
+ */
DataType[] dataType() default DataType.All;
}
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/annotation/AlgorithmAnnotations.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/annotation/AlgorithmAnnotations.java
index 1c9c7fb83b..dc8cabac6a 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/annotation/AlgorithmAnnotations.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/annotation/AlgorithmAnnotations.java
@@ -27,6 +27,8 @@
import java.util.List;
/**
+ * Annotations for algorithms.
+ *
* Sep 26, 2017 12:19:41 AM
*
* @author Kevin V. Bui (kvb2@pitt.edu)
@@ -39,34 +41,74 @@ private AlgorithmAnnotations() {
super("edu.cmu.tetrad.algcomparison.algorithm", Algorithm.class);
}
+ /**
+ * Gets the instance of this class.
+ * @return instance of this class
+ */
public static AlgorithmAnnotations getInstance() {
return AlgorithmAnnotations.INSTANCE;
}
+ /**
+ * Filters out algorithms that are not for the given data type.
+ * @param list list of algorithms
+ * @return list of algorithms that are not for the given data type
+ */
public List> filterOutExperimental(List> list) {
return filterOutByAnnotation(list, Experimental.class);
}
+ /**
+ * Checks if the algorithm takes multiple data sets.
+ * @param clazz algorithm class
+ * @return true if the algorithm takes multiple data sets
+ */
public boolean takesMultipleDataset(Class clazz) {
return clazz != null && MultiDataSetAlgorithm.class.isAssignableFrom(clazz);
}
+ /**
+ * Checks if the algorithm takes knowledge.
+ * @param clazz algorithm class
+ * @return true if the algorithm takes knowledge
+ */
public boolean takesKnowledge(Class clazz) {
return clazz != null && HasKnowledge.class.isAssignableFrom(clazz);
}
+ /**
+ * Checks if the algorithm takes an external graph.
+ * @param clazz algorithm class
+ * @return true if the algorithm takes an external graph
+ */
public boolean takesExternalGraph(Class clazz) {
return clazz != null && TakesExternalGraph.class.isAssignableFrom(clazz);
}
+ /**
+ * Checks if the algorithm requires independence test.
+ * @param clazz algorithm class
+ * @return true if the algorithm requires independence test
+ */
public boolean requiresIndependenceTest(Class clazz) {
return clazz != null && TakesIndependenceWrapper.class.isAssignableFrom(clazz);
}
+ /**
+ * Checks if the algorithm requires a score.
+ * @param clazz algorithm class
+ * @return true if the algorithm requires a score
+ */
public boolean requiresScore(Class clazz) {
return clazz != null && UsesScoreWrapper.class.isAssignableFrom(clazz);
}
+ /**
+ * Checks if the algorithm handles unmeasured confounders.
+ *
+ * @param clazz algorithm class
+ * @return true if the algorithm handles unmeasured confounders
+ */
public boolean handlesUnmeasuredConfounder(Class clazz) {
return clazz != null && clazz.isAnnotationPresent(UnmeasuredConfounder.class);
}
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/annotation/AnnotatedClass.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/annotation/AnnotatedClass.java
index 0a3bb1d043..a56a602075 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/annotation/AnnotatedClass.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/annotation/AnnotatedClass.java
@@ -35,15 +35,28 @@ public class AnnotatedClass implements Serializable {
private final T annotation;
+ /**
+ * Creates an annotated class.
+ * @param clazz class
+ * @param annotation annotation
+ */
public AnnotatedClass(Class clazz, T annotation) {
this.clazz = clazz;
this.annotation = annotation;
}
+ /**
+ * Gets the class.
+ * @return class
+ */
public Class getClazz() {
return this.clazz;
}
+ /**
+ * Gets the annotation.
+ * @return annotation
+ */
public T getAnnotation() {
return this.annotation;
}
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/annotation/AnnotatedClassUtils.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/annotation/AnnotatedClassUtils.java
index de6bbc5d8f..ca4a8180d2 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/annotation/AnnotatedClassUtils.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/annotation/AnnotatedClassUtils.java
@@ -36,6 +36,13 @@ public class AnnotatedClassUtils {
private AnnotatedClassUtils() {
}
+ /**
+ * Gets a list of annotated classes in the given package.
+ * @param packageName package name
+ * @param type annotation type
+ * @return list of annotated classes
+ * @param annotation type.
+ */
public static List> getAnnotatedClasses(String packageName, Class type) {
Reflections reflections = new Reflections(packageName);
Set> classes = reflections.getTypesAnnotatedWith(type);
@@ -45,6 +52,13 @@ public static List> getAnnotatedClasses
.collect(Collectors.toList());
}
+ /**
+ * Filters a list of annotated classes by the given annotation.
+ * @param annotation annotation
+ * @param annotatedClasses list of annotated classes
+ * @return list of annotated classes
+ * @param annotation type.
+ */
public static List> filterByAnnotations(Class extends Annotation> annotation, List> annotatedClasses) {
List> list = new LinkedList<>();
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/ApproximateUpdater.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/ApproximateUpdater.java
index 60a9835256..41578750a2 100755
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/ApproximateUpdater.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/ApproximateUpdater.java
@@ -40,7 +40,7 @@
* @author josephramsey
*/
public final class ApproximateUpdater implements ManipulatingBayesUpdater {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
/**
* The IM which this updater modifies.
@@ -72,6 +72,10 @@ public final class ApproximateUpdater implements ManipulatingBayesUpdater {
//==============================CONSTRUCTORS===========================//
+ /**
+ * Constructs a new updater for the given Bayes net.
+ * @param bayesIm the Bayes net to be updated.
+ */
public ApproximateUpdater(BayesIm bayesIm) {
if (bayesIm == null) {
throw new NullPointerException();
@@ -83,6 +87,8 @@ public ApproximateUpdater(BayesIm bayesIm) {
/**
* Constructs a new updater for the given Bayes net.
+ * @param bayesIm the Bayes net to be updated.
+ * @param evidence the evidence for the update.
*/
public ApproximateUpdater(BayesIm bayesIm, Evidence evidence) {
if (bayesIm == null) {
@@ -94,6 +100,7 @@ public ApproximateUpdater(BayesIm bayesIm, Evidence evidence) {
}
/**
+ * Returns a simple exemplar of this class to test serialization.
* @return a simple exemplar of this class to test serialization.
*/
public static ApproximateUpdater serializableInstance() {
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/BayesIm.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/BayesIm.java
index a08ab7bd04..3a44dcdf56 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/BayesIm.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/BayesIm.java
@@ -52,53 +52,75 @@
public interface BayesIm extends VariableSource, Im, Simulator {
/**
+ * Returns the underlying Bayes PM.
+ *
* @return the underlying Bayes PM.
*/
BayesPm getBayesPm();
/**
+ * $Description
+ *
* @return the underlying DAG.
*/
Graph getDag();
/**
+ * Returns the name of the given node.
+ *
* @return the number of nodes in the model.
*/
int getNumNodes();
/**
+ * Returns the name of the given node.
+ *
+ * @param nodeIndex the index of the node.
* @return the node corresponding to the given node index.
*/
Node getNode(int nodeIndex);
/**
+ * Returns the name of the given node.
+ *
* @param name the name of the node.
* @return the node with the given name in the associated graph.
*/
Node getNode(String name);
/**
+ * Returns the index of the given node.
+ *
* @param node the given node.
* @return the index for that node, or -1 if the node is not in the BayesIm.
*/
int getNodeIndex(Node node);
/**
+ * Returns the list of variables.
+ *
* @return the list of variable for this Bayes net.
*/
List getVariables();
/**
+ * Returns the list of variable names.
+ *
* @return the list of variable names for this Bayes net.
*/
List getVariableNames();
/**
+ * Returns the list of measured variables.
+ *
* @return the list of measured variableNodes.
*/
List getMeasuredNodes();
/**
+ * Returns the number of columns.
+ *
+ * @param nodeIndex the index of the node.
* @return the number of columns in the table of the given node N with index 'nodeIndex'--that is, the number of
* possible values that N can take on. That is, if P(N=v0 | P1=v1, P2=v2, ... Pn=vn) is a conditional probability
* stored in 'probs', then the maximum number of rows in the table for N is #vals(N).
@@ -107,6 +129,9 @@ public interface BayesIm extends VariableSource, Im, Simulator {
int getNumColumns(int nodeIndex);
/**
+ * Returns the number of rows.
+ *
+ * @param nodeIndex the index of the node.
* @return the number of rows in the table of the given node, which would be the total number of possible
* combinations of parent values for a given node. That is, if P(N=v0 | P1=v1, P2=v2, ... Pn=vn) is a conditional
* probability stored in 'probs', then the maximum number of rows in the table for N is #vals(P1) x #vals(P2) x ...
@@ -117,22 +142,35 @@ public interface BayesIm extends VariableSource, Im, Simulator {
int getNumRows(int nodeIndex);
/**
+ * Returns the number of parents for the given node.
+ *
* @param nodeIndex the given node.
* @return the number of parents of the given node.
*/
int getNumParents(int nodeIndex);
/**
+ * Returns the ith parent of the givne node.
+ *
+ * @param nodeIndex the index of the node.
+ * @param parentIndex the index of the parent.
* @return the given parent of the given node.
*/
int getParent(int nodeIndex, int parentIndex);
/**
+ * Returns the dimension of the given parent for the given node.
+ *
+ * @param nodeIndex the index of the node.
+ * @param parentIndex the index of the parent.
* @return the dimension of the given parent for the given node.
*/
int getParentDim(int nodeIndex, int parentIndex);
/**
+ * Returns the dimensions of the pararents of the given node.
+ *
+ * @param nodeIndex the index of the node.
* @return (a defensive copy of) the array representing the dimensionality of each parent of a node, that is, the
* number of values which that node can take on. The order of entries in this array is the same as the order of
* entries of nodes returned by getParents() for that node.
@@ -141,6 +179,9 @@ public interface BayesIm extends VariableSource, Im, Simulator {
int[] getParentDims(int nodeIndex);
/**
+ * Returns the parents of the given node.
+ *
+ * @param nodeIndex the index of the node.
* @return (a defensive copy of) the array containing all of the parents of a given node in the order in which they
* are stored internally.
* @see #getParentDims
@@ -148,6 +189,8 @@ public interface BayesIm extends VariableSource, Im, Simulator {
int[] getParents(int nodeIndex);
/**
+ * Returns the parents values of the given node.
+ *
* @param nodeIndex the index of the node.
* @param rowIndex the index of the row in question.
* @return an array containing the combination of parent values for a given node and given row in the probability
@@ -164,11 +207,18 @@ public interface BayesIm extends VariableSource, Im, Simulator {
int[] getParentValues(int nodeIndex, int rowIndex);
/**
+ * Returns the given parent value.
+ *
+ * @param nodeIndex the index of the node.
+ * @param rowIndex the index of the row in question.
+ * @param colIndex the index of the column in question.
* @return the value in the probability table for the given node, at the given row and column.
*/
int getParentValue(int nodeIndex, int rowIndex, int colIndex);
/**
+ * Returns the probability for the given cell in the given CPT.
+ *
* @param nodeIndex the index of the node in question.
* @param rowIndex the row in the table for this for node which represents the combination of parent values in
* question.
@@ -184,6 +234,8 @@ public interface BayesIm extends VariableSource, Im, Simulator {
double getProbability(int nodeIndex, int rowIndex, int colIndex);
/**
+ * Returns a row index.
+ *
* @return the row in the table at which the given combination of parent values is represented for the given node.
* The row is calculated as a variable-base place-value number. For instance, if the array of parent dimensions is
* [3, 5, 7] and the parent value combination is [2, 4, 5], then the row number is (7 * (5 * (3 * 0 + 2) + 4)) + 5 =
@@ -191,6 +243,8 @@ public interface BayesIm extends VariableSource, Im, Simulator {
*
* Note: If the node has n values, the length of 'values' must be >= the number of parents. Only the first n
* values are used.
+ * @param nodeIndex the index of the node in question.
+ * @param values the combination of parent values in question.
* @see #getParentValues
*/
int getRowIndex(int nodeIndex, int[] values);
@@ -202,11 +256,16 @@ public interface BayesIm extends VariableSource, Im, Simulator {
/**
* Normalizes all rows in the table associated with a given node.
+ *
+ * @param nodeIndex the index of the node in question.
*/
void normalizeNode(int nodeIndex);
/**
* Normalizes the given row.
+ *
+ * @param nodeIndex the index of the node in question.
+ * @param rowIndex the index of the row in question.
*/
void normalizeRow(int nodeIndex, int rowIndex);
@@ -224,8 +283,7 @@ public interface BayesIm extends VariableSource, Im, Simulator {
* @param value the desired probability to be set.
* @see #getProbability
*/
- void setProbability(int nodeIndex, int rowIndex, int colIndex,
- double value);
+ void setProbability(int nodeIndex, int rowIndex, int colIndex, double value);
/**
* Sets the probability for the given node. The matrix row represent row index, the row in the table for this for
@@ -238,6 +296,10 @@ void setProbability(int nodeIndex, int rowIndex, int colIndex,
void setProbability(int nodeIndex, double[][] probMatrix);
/**
+ * Returns the index of the given node in the given BayesIm.
+ *
+ * @param otherBayesIm the BayesIm in which the node is to be found.
+ * @param nodeIndex the index of the node in this BayesIm.
* @return the index of the node with the given name in the specified BayesIm.
*/
int getCorrespondingNodeIndex(int nodeIndex, BayesIm otherBayesIm);
@@ -280,11 +342,18 @@ void setProbability(int nodeIndex, int rowIndex, int colIndex,
void clearTable(int nodeIndex);
/**
+ * Returns true iff the given row in the given node has a Double.NaN value in it.
+ *
+ * @param nodeIndex the node for the table whose incomplete rows are to be checked.
+ * @param rowIndex the index of the row in question.
* @return true iff one of the values in the given row is Double.NaN.
*/
boolean isIncomplete(int nodeIndex, int rowIndex);
/**
+ * Returns true iff the given node has a Double.NaN value in it.
+ *
+ * @param nodeIndex the node for the table whose incomplete rows are to be checked.
* @return true iff any value in the table for the given node is Double.NaN.
*/
boolean isIncomplete(int nodeIndex);
@@ -293,33 +362,34 @@ void setProbability(int nodeIndex, int rowIndex, int colIndex,
* Simulates a sample with the given sample size.
*
* @param sampleSize the sample size.
+ * @param latentDataSaved true iff the latent data is to be saved.
* @return the simulated sample as a DataSet.
*/
DataSet simulateData(int sampleSize, boolean latentDataSaved);
-// /**
-// * Simulates a sample with the given sample size.
-// *
-// * @param sampleSize the sample size.
-// * @return the simulated sample as a DataSet.
-// */
-// DataSet simulateData(int sampleSize, long seed, boolean latentDataSaved);
-
/**
* Overwrites the given dataSet with a new simulated dataSet, to avoid allocating memory. The given dataSet must
* have the necessary number of columns.
*
+ * @param dataSet the dataSet to be overwritten.
+ * @param latentDataSaved true iff the latent data is to be saved.
* @return the simulated sample as a DataSet.
*/
DataSet simulateData(DataSet dataSet, boolean latentDataSaved);
/**
+ * Returns true iff this Bayes net is equal to the given Bayes net. The sense of equality may vary depending on the
+ * type of Bayes net.
+ *
+ * @param o the Bayes net to be compared to this Bayes net.
* @return true iff this bayes net is equal to the given Bayes net. The sense of equality may vary depending on the
* type of Bayes net.
*/
boolean equals(Object o);
/**
+ * Returns a string representation for this Bayes net.
+ *
* @return a string representation for this Bayes net.
*/
String toString();
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/BayesImProbs.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/BayesImProbs.java
index f9458d46db..fc82053648 100755
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/BayesImProbs.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/BayesImProbs.java
@@ -38,7 +38,7 @@
* @author josephramsey
*/
public final class BayesImProbs implements DiscreteProbs, TetradSerializable {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
/**
* @serial Cannot be null.
@@ -52,6 +52,10 @@ public final class BayesImProbs implements DiscreteProbs, TetradSerializable {
//===========================CONSTRUCTORS==========================//
+ /**
+ * Constructs a BayesImProbs object from the given BayesIm.
+ * @param bayesIm Ibid.
+ */
public BayesImProbs(BayesIm bayesIm) {
if (bayesIm == null) {
throw new NullPointerException();
@@ -80,6 +84,8 @@ public BayesImProbs(BayesIm bayesIm) {
/**
* Generates a simple exemplar of this class to test serialization.
+ *
+ * @return a simple exemplar of this class to test serialization.
*/
public static BayesImProbs serializableInstance() {
return new BayesImProbs(MlBayesIm.serializableInstance());
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/BayesPm.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/BayesPm.java
index 5aa5e791e1..58e48f7815 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/BayesPm.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/BayesPm.java
@@ -44,7 +44,7 @@
* @see BayesIm
*/
public final class BayesPm implements Pm, VariableSource {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
/**
* The underlying graph that's being parameterized.
@@ -65,6 +65,8 @@ public final class BayesPm implements Pm, VariableSource {
/**
* Construct a new BayesPm using the given DAG, assigning each variable two values named "value1" and "value2"
* unless nodes are discrete variables with categories already defined.
+ *
+ * @param graph Ibid.
*/
public BayesPm(Graph graph) {
if (graph == null) {
@@ -92,6 +94,9 @@ public BayesPm(Graph graph) {
/**
* Constructs a new BayesPm using a given DAG, using as much information from the old BayesPm as possible.
+ *
+ * @param graph Ibid.
+ * @param oldBayesPm Ibid.
*/
public BayesPm(Graph graph, BayesPm oldBayesPm) {
this(graph, oldBayesPm, 2, 2);
@@ -102,6 +107,10 @@ public BayesPm(Graph graph, BayesPm oldBayesPm) {
* lowerBound
and
* upperBound
. Uses a fixed number of values if lowerBound ==
* upperBound. The values are named "value1" ... "valuen".
+ *
+ * @param graph Ibid.
+ * @param lowerBound Ibid.
+ * @param upperBound Ibid.
*/
public BayesPm(Graph graph, int lowerBound, int upperBound) {
if (graph == null) {
@@ -118,6 +127,11 @@ public BayesPm(Graph graph, int lowerBound, int upperBound) {
* variables not in the old BayesPm, assigns each variable a random number of values between
* lowerBound
and upperBound
. Uses a fixed number
* of values if lowerBound == upperBound. The values are named "value1" ... "valuen".
+ *
+ * @param graph Ibid.
+ * @param oldBayesPm Ibid.
+ * @param lowerBound Ibid.
+ * @param upperBound Ibid.
*/
public BayesPm(Graph graph, BayesPm oldBayesPm, int lowerBound,
int upperBound) {
@@ -145,6 +159,8 @@ public BayesPm(Graph graph, BayesPm oldBayesPm, int lowerBound,
/**
* Copy constructor.
+ *
+ * @param bayesPm Ibid.
*/
public BayesPm(BayesPm bayesPm) {
this.dag = bayesPm.dag;
@@ -162,6 +178,8 @@ public BayesPm(BayesPm bayesPm) {
/**
* Generates a simple exemplar of this class to test serialization.
+ *
+ * @return Ibid.
*/
public static BayesPm serializableInstance() {
return new BayesPm(Dag.serializableInstance());
@@ -170,6 +188,11 @@ public static BayesPm serializableInstance() {
//=========================PUBLIC METHODS=============================//
+ /**
+ * Returns the parameter names.
+ *
+ * @return Ibid.
+ */
public static List getParameterNames() {
List parameters = new ArrayList<>();
parameters.add("minCategories");
@@ -194,6 +217,8 @@ private static int pickNumVals(int lowerBound, int upperBound) {
}
/**
+ * Returns the DAG.
+ *
* @return the DAG as a Graph.
*/
public Graph getDag() {
@@ -201,6 +226,9 @@ public Graph getDag() {
}
/**
+ * Returns the number of values for the given node.
+ *
+ * @param node Ibid.
* @return the number of values for the given node.
*/
public int getNumCategories(Node node) {
@@ -214,6 +242,10 @@ public int getNumCategories(Node node) {
}
/**
+ * Returns the index'th value for the given node.
+ *
+ * @param node Ibid.
+ * @param index Ibid.
* @return the index'th value for the given node.
*/
public String getCategory(Node node, int index) {
@@ -237,6 +269,10 @@ public String getCategory(Node node, int index) {
}
/**
+ * Returns the index of the given category for the given node.
+ *
+ * @param node Ibid.
+ * @param category Ibid.
* @return the index of the given category for the given node.
*/
public int getCategoryIndex(Node node, String category) {
@@ -246,6 +282,9 @@ public int getCategoryIndex(Node node, String category) {
/**
* Sets the number of values for the given node to the given number.
+ *
+ * @param node Ibid.
+ * @param numCategories Ibid.
*/
public void setNumCategories(Node node, int numCategories) {
if (!this.nodesToVariables.containsKey(node)) {
@@ -283,6 +322,8 @@ public void setNumCategories(Node node, int numCategories) {
/**
* Will return true if the argument is a BayesPm with the same graph and variables.
+ *
+ * @param o Ibid.
*/
public boolean equals(Object o) {
if (o == null) {
@@ -299,6 +340,12 @@ public boolean equals(Object o) {
}
+ /**
+ * Sets the number of values for the given node to the given number.
+ *
+ * @param node Ibid.
+ * @param categories Ibid.
+ */
public void setCategories(Node node, List categories) {
mapNodeToVariable(node, categories);
}
@@ -313,6 +360,11 @@ public List getVariables() {
return variables;
}
+ /**
+ * Returns the variable names.
+ *
+ * @return Ibid.
+ */
public List getVariableNames() {
List variables = getVariables();
List names = new ArrayList<>();
@@ -325,11 +377,19 @@ public List getVariableNames() {
return names;
}
+ /**
+ * Returns the variable for the given node.
+ *
+ * @param node Ibid.
+ * @return Ibid.
+ */
public Node getVariable(Node node) {
return this.nodesToVariables.get(node);
}
/**
+ * Returns the measured nodes.
+ *
* @return the list of measured variableNodes.
*/
public List getMeasuredNodes() {
@@ -346,6 +406,7 @@ public List getMeasuredNodes() {
/**
* Prints out the list of values for each node.
+ * @return Ibid.
*/
public String toString() {
StringBuilder buf = new StringBuilder();
@@ -368,24 +429,42 @@ public String toString() {
return buf.toString();
}
+ /**
+ * Returns the node by the given name.
+ * @param nodeName Ibid.
+ * @return Ibid.
+ */
public Node getNode(String nodeName) {
return this.dag.getNode(nodeName);
}
+ /**
+ * Returns the node at the given index.
+ * @param index Ibid.
+ * @return Ibid.
+ */
public Node getNode(int index) {
return getVariables().get(index);
}
+ /**
+ * Returns the node index.
+ * @return -1.
+ */
public int getNodeIndex() {
return -1;
}
- //=========================PRIVATE METHODS=============================//
-
+ /**
+ * Returns the number of nodes.
+ * @return Ibid.
+ */
public int getNumNodes() {
return this.dag.getNumNodes();
}
+ //=========================PRIVATE METHODS=============================//
+
private void copyAvailableInformationFromOldBayesPm(BayesPm oldbayesPm,
int lowerBound, int upperBound) {
Graph newGraph = getDag();
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/BayesProperties.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/BayesProperties.java
index b57a007d69..37a811b5ff 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/BayesProperties.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/BayesProperties.java
@@ -101,6 +101,8 @@ private static int getRowIndex(int[] dim, int[] values) {
/**
* Calculates the p-value of the graph with respect to the given data.
+ *
+ * @param graph The graph.
*/
public LikelihoodRet getLikelihoodRatioP(Graph graph) {
@@ -154,6 +156,8 @@ public LikelihoodRet getLikelihoodRatioP(Graph graph) {
/**
* Call after calling getLikelihoodP().
+ *
+ * @return The chi-squared statistic.
*/
public double getChisq() {
return this.chisq;
@@ -161,6 +165,8 @@ public double getChisq() {
/**
* Call after calling getLikelihoodP().
+ *
+ * @return The degrees of freedom.
*/
public double getDof() {
return this.dof;
@@ -168,6 +174,8 @@ public double getDof() {
/**
* Call after calling getLikelihoodP().
+ *
+ * @return The BIC.
*/
public double getBic() {
return this.bic;
@@ -175,6 +183,8 @@ public double getBic() {
/**
* Call after calling getLikelihoodP().
+ *
+ * @return The likelihood.
*/
public double getLikelihood() {
return this.likelihood;
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/BayesUpdater.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/BayesUpdater.java
index 606afb1368..4dbfa13c2f 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/BayesUpdater.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/BayesUpdater.java
@@ -39,32 +39,58 @@ public interface BayesUpdater extends TetradSerializable {
long serialVersionUID = 23L;
/**
+ * Returns the marginal probability of the given variable taking the given value, given the evidence.
+ *
+ * @param variable variable index
+ * @param category category index
* @return P(variable = value | evidence), where evidence is getEvidence().
*/
double getMarginal(int variable, int category);
/**
+ * Returns the joint marginal probability of the given variables taking the given values, given the evidence.
+ *
* @return true if the getJointMarginal() method is supported.
*/
boolean isJointMarginalSupported();
/**
+ * Returns the joint marginal probability of the given variables taking the given values, given the evidence.
+ *
+ * @param variables variable indices
+ * @param values category indices
* @return P(variables[i] = values[i] | evidence), where evidence is getEvidence().
*/
double getJointMarginal(int[] variables, int[] values);
/**
* Sets new evidence for the updater. Once this is called, old updating results should not longer be available.
+ *
+ * @param evidence evidence
*/
void setEvidence(Evidence evidence);
/**
+ * Returns the evidence for the updater.
+ *
* @return the Bayes instantiated model that is being updated.
*/
BayesIm getBayesIm();
+ /**
+ * Calculates the prior marginal probabilities of the given node.
+ *
+ * @param nodeIndex node index
+ * @return P(node = value), where value is the value of the node in the Bayes net.
+ */
double[] calculatePriorMarginals(int nodeIndex);
+ /**
+ * Calculates the updated marginal probabilities of the given node, given the evidence.
+ *
+ * @param nodeIndex node index
+ * @return P(node = value | evidence), where value is the value of the node in the Bayes net.
+ */
double[] calculateUpdatedMarginals(int nodeIndex);
}
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/CptInvariantMarginalCalculator.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/CptInvariantMarginalCalculator.java
index 08ea5531e9..f273fd1638 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/CptInvariantMarginalCalculator.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/CptInvariantMarginalCalculator.java
@@ -35,7 +35,7 @@
*/
public final class CptInvariantMarginalCalculator
implements TetradSerializable {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
/**
* @serial Cannot be null.
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/CptInvariantUpdater.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/CptInvariantUpdater.java
index d33a8f0ab4..da910e533f 100755
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/CptInvariantUpdater.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/CptInvariantUpdater.java
@@ -37,7 +37,7 @@
* @author josephramsey
*/
public final class CptInvariantUpdater implements ManipulatingBayesUpdater {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
/**
* The IM which this updater modifies.
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/DataSetProbs.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/DataSetProbs.java
index a7bd84ab85..3ce6c9d218 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/DataSetProbs.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/DataSetProbs.java
@@ -36,7 +36,7 @@
* @author josephramsey
*/
public final class DataSetProbs implements DiscreteProbs {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
/**
* The data set that this is a cell count table for.
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/DirichletBayesIm.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/DirichletBayesIm.java
index 7b6716e24a..007a3e390e 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/DirichletBayesIm.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/DirichletBayesIm.java
@@ -67,7 +67,7 @@
*/
public final class DirichletBayesIm implements BayesIm {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
private static final double ALLOWABLE_DIFFERENCE = 1.0e-10;
/**
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/Evidence.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/Evidence.java
index 1d83f30c2b..081e6581a1 100755
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/Evidence.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/Evidence.java
@@ -38,7 +38,7 @@
* @author josephramsey
*/
public final class Evidence implements TetradSerializable {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
/**
* A proposition stating what we know for each variable.
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/Identifiability.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/Identifiability.java
index d731f9dd45..e1098bc4c3 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/Identifiability.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/Identifiability.java
@@ -38,7 +38,7 @@
* @author Choh Man Teng
*/
public final class Identifiability implements ManipulatingBayesUpdater {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
/**
* The BayesIm which this updater modifies.
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/JunctionTreeAlgorithm.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/JunctionTreeAlgorithm.java
index ccb80213af..c92d831d61 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/JunctionTreeAlgorithm.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/JunctionTreeAlgorithm.java
@@ -39,7 +39,7 @@
* href="https://raw.githubusercontent.com/Waikato/weka-3.8/master/weka/src/main/java/weka/classifiers/bayes/net/MarginCalculator.java">MarginCalculator.java
*/
public class JunctionTreeAlgorithm implements TetradSerializable {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
private final TreeNode root;
@@ -546,7 +546,7 @@ public String toString() {
private class TreeSeparator implements TetradSerializable {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
private final double[] parentPotentials;
private final double[] childPotentials;
@@ -600,7 +600,7 @@ public void updateFromChild() {
private class TreeNode implements TetradSerializable {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
/**
* Distribution over this junction node according to its potentials.
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/JunctionTreeUpdater.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/JunctionTreeUpdater.java
index 29e1eb13c1..0dfed40047 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/JunctionTreeUpdater.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/JunctionTreeUpdater.java
@@ -32,7 +32,7 @@
* @author Kevin V. Bui (kvb2@pitt.edu)
*/
public class JunctionTreeUpdater implements ManipulatingBayesUpdater {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
/**
* The BayesIm which this updater modifies.
*
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/ManipulatingBayesUpdater.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/ManipulatingBayesUpdater.java
index f3163c24e4..6b2afed2fa 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/ManipulatingBayesUpdater.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/ManipulatingBayesUpdater.java
@@ -33,32 +33,46 @@ public interface ManipulatingBayesUpdater extends BayesUpdater {
long serialVersionUID = 23L;
/**
+ * Returns the manipulated Bayes IM. This is the Bayes IM in which the variables in the manipulation have been
+ * removed from the graph.
+ *
* @return the Bayes instantiated model after manipulations have been applied.
*/
BayesIm getManipulatedBayesIm();
/**
+ * Returns the manipulated graph. This is the graph in which the variables in the manipulation have been removed
+ * from the graph.
+ *
* @return the graph for the manipulated BayesIm.
*/
Graph getManipulatedGraph();
/**
+ * Returns the manipulation that was used to manipulate the Bayes IM.
+ *
* @return a defensive copy of the evidence.
*/
Evidence getEvidence();
/**
* Sets new evidence for the updater. Once this is called, old updating results should not longer be available.
+ *
+ * @param evidence the new evidence.
*/
void setEvidence(Evidence evidence);
/**
+ * Returns the updated Bayes IM. This is the Bayes IM in which all probabilities of variables conditional on their
+ * parents have been updated.
* @return the updated Bayes IM--that is, the Bayes IM in which all probabilities of variables conditional on their
* parents have been updated.
*/
BayesIm getUpdatedBayesIm();
/**
+ * Returns the updated graph. This is the graph in which all probabilities of variables conditional on their
+ * parents have been updated.
* @return P(variable = category | evidence) where evidence is getEvidence().
*/
double getMarginal(int variable, int category);
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/Manipulation.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/Manipulation.java
index a39ec6d88a..b7f86d02de 100755
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/Manipulation.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/Manipulation.java
@@ -35,7 +35,7 @@
* @author josephramsey
*/
public final class Manipulation implements TetradSerializable {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
private final VariableSource variableSource;
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/MlBayesIm.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/MlBayesIm.java
index b538aa8a3b..77003ff05c 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/MlBayesIm.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/MlBayesIm.java
@@ -76,7 +76,7 @@ public final class MlBayesIm implements BayesIm {
* Indicates that new rows in this BayesIm should be initialized randomly.
*/
public static final int RANDOM = 1;
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
private static final double ALLOWABLE_DIFFERENCE = 1.0e-3;
/**
@@ -944,7 +944,7 @@ private DataSet simulateDataHelper(int sampleSize, boolean latentDataSaved, int[
constructSample(sampleSize, dataSet, map, tiers);
if (!latentDataSaved) {
- dataSet = DataUtils.restrictToMeasured(dataSet);
+ dataSet = DataTransforms.restrictToMeasured(dataSet);
}
return dataSet;
@@ -994,7 +994,7 @@ private DataSet simulateDataHelper(DataSet dataSet, boolean latentDataSaved, int
if (latentDataSaved) {
return dataSet;
} else {
- return DataUtils.restrictToMeasured(dataSet);
+ return DataTransforms.restrictToMeasured(dataSet);
}
}
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/MlBayesImObs.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/MlBayesImObs.java
index d22f9e4ddc..9fff8d6ca5 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/MlBayesImObs.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/MlBayesImObs.java
@@ -65,7 +65,7 @@
*/
public final class MlBayesImObs implements BayesIm {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
private static final double ALLOWABLE_DIFFERENCE = 1.0e-10;
/**
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/Proposition.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/Proposition.java
index 10d591f614..2a1782731b 100755
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/Proposition.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/Proposition.java
@@ -42,7 +42,7 @@
* @author josephramsey
*/
public final class Proposition implements TetradSerializable {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
/**
* @serial Cannot be null.
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/RowSummingExactUpdater.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/RowSummingExactUpdater.java
index b2bf4e2d87..fd4a16398f 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/RowSummingExactUpdater.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/RowSummingExactUpdater.java
@@ -37,7 +37,7 @@
* @author josephramsey
*/
public final class RowSummingExactUpdater implements ManipulatingBayesUpdater {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
/**
* The BayesIm which this updater modifies.
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/StoredCellProbs.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/StoredCellProbs.java
index a311cbed4c..36c3e6225f 100755
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/StoredCellProbs.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/StoredCellProbs.java
@@ -38,7 +38,7 @@
* @author josephramsey
*/
public final class StoredCellProbs implements TetradSerializable, DiscreteProbs {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
private final List variables;
private final int[] parentDims;
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/StoredCellProbsObs.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/StoredCellProbsObs.java
index 7b4086ed9a..b077d7b218 100755
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/StoredCellProbsObs.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/StoredCellProbsObs.java
@@ -42,7 +42,7 @@
//////////////////////////////////////////////////////////////////////
public final class StoredCellProbsObs implements TetradSerializable, DiscreteProbs {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
private final List variables;
private final int[] parentDims;
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/UpdatedBayesIm.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/UpdatedBayesIm.java
index 3496d9aba7..b4730e1fef 100755
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/UpdatedBayesIm.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/UpdatedBayesIm.java
@@ -41,7 +41,7 @@
*/
public final class UpdatedBayesIm implements BayesIm {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
private static final double ALLOWABLE_DIFFERENCE = 1.0e-10;
/**
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/calculator/expression/AbstractExpression.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/calculator/expression/AbstractExpression.java
index 030229d3c3..198b8d93a8 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/calculator/expression/AbstractExpression.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/calculator/expression/AbstractExpression.java
@@ -34,7 +34,7 @@
* @author Tyler Gibson
*/
abstract class AbstractExpression implements Expression {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
/**
* The sub expressionts
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/calculator/expression/AbstractExpressionDescriptor.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/calculator/expression/AbstractExpressionDescriptor.java
index 09caaf05b2..3ad1dc3ffc 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/calculator/expression/AbstractExpressionDescriptor.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/calculator/expression/AbstractExpressionDescriptor.java
@@ -27,7 +27,7 @@
* @author Tyler Gibson
*/
abstract class AbstractExpressionDescriptor implements ExpressionDescriptor {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
/**
* The human-readable name for the descriptor.
@@ -111,7 +111,7 @@ public boolean isDisplay() {
* Basic implementation of expression signature.
*/
public static class Signature implements ExpressionSignature {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
private final String[] arguments;
private String signature;
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/calculator/expression/ConstantExpression.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/calculator/expression/ConstantExpression.java
index 709aae9f38..0e5a181321 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/calculator/expression/ConstantExpression.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/calculator/expression/ConstantExpression.java
@@ -42,7 +42,7 @@ public class ConstantExpression implements Expression {
* Constant expression for e.
*/
public static final ConstantExpression E = new ConstantExpression(FastMath.E, "E");// "e");
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
/**
* THe value of the expression.
*/
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/calculator/expression/EvaluationExpression.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/calculator/expression/EvaluationExpression.java
index 716300dac9..71399412f8 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/calculator/expression/EvaluationExpression.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/calculator/expression/EvaluationExpression.java
@@ -33,7 +33,7 @@
* @author Tyler Gibson
*/
public class EvaluationExpression implements Expression {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
/**
* The variable part of the expression.
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/calculator/expression/ExpressionDescriptor.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/calculator/expression/ExpressionDescriptor.java
index 532a605ad0..cb6c18ef9a 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/calculator/expression/ExpressionDescriptor.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/calculator/expression/ExpressionDescriptor.java
@@ -63,7 +63,7 @@ enum Position implements TetradSerializable {
PREFIX,
BOTH;
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public static Position serializableInstance() {
return Position.NEITHER;
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/calculator/expression/ExpressionManager.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/calculator/expression/ExpressionManager.java
index 0ac9b15a97..0510fefd43 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/calculator/expression/ExpressionManager.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/calculator/expression/ExpressionManager.java
@@ -193,7 +193,7 @@ public ExpressionDescriptor getDescriptorFromToken(String token) {
* Addition
*/
private static class AdditionExpressionDescriptor extends AbstractExpressionDescriptor {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public AdditionExpressionDescriptor() {
@@ -204,7 +204,7 @@ public AdditionExpressionDescriptor() {
public Expression createExpression(Expression... expressions) throws ExpressionInitializationException {
if (expressions.length > 0) {
return new AbstractExpression("+", Position.BOTH, expressions) {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public double evaluate(Context context) {
double value = 0.0;
@@ -233,7 +233,7 @@ public double evaluate(Context context) {
* Addition
*/
private static class SubtractionExpressionDescriptor extends AbstractExpressionDescriptor {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public SubtractionExpressionDescriptor() {
@@ -244,7 +244,7 @@ public SubtractionExpressionDescriptor() {
public Expression createExpression(Expression... expressions) throws ExpressionInitializationException {
if (expressions.length == 1) {
return new AbstractExpression("-", Position.INFIX, expressions) {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public double evaluate(Context context) {
return -getExpressions().get(0).evaluate(context);
@@ -252,7 +252,7 @@ public double evaluate(Context context) {
};
} else if (expressions.length == 2) {
return new AbstractExpression("-", Position.INFIX, expressions) {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public double evaluate(Context context) {
return getExpressions().get(0).evaluate(context) - getExpressions().get(1).evaluate(context);
@@ -269,7 +269,7 @@ public double evaluate(Context context) {
* Ceil
*/
private static class CeilExpressionDescriptor extends AbstractExpressionDescriptor {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public CeilExpressionDescriptor() {
@@ -283,7 +283,7 @@ public Expression createExpression(Expression... expressions) throws ExpressionI
" argument.");
}
return new AbstractExpression("ceil", Position.PREFIX, expressions) {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public double evaluate(Context context) {
return FastMath.ceil(getExpressions().get(0).evaluate(context));
@@ -293,7 +293,7 @@ public double evaluate(Context context) {
}
private static class SignumExpressionDescriptor extends AbstractExpressionDescriptor {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public SignumExpressionDescriptor() {
@@ -307,7 +307,7 @@ public Expression createExpression(Expression... expressions) throws ExpressionI
" argument.");
}
return new AbstractExpression("signum", Position.PREFIX, expressions) {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public double evaluate(Context context) {
return FastMath.signum(getExpressions().get(0).evaluate(context));
@@ -320,7 +320,7 @@ public double evaluate(Context context) {
* Cosine
*/
private static class CosExpressionDescriptor extends AbstractExpressionDescriptor {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public CosExpressionDescriptor() {
@@ -334,7 +334,7 @@ public Expression createExpression(Expression... expressions) throws ExpressionI
" argument.");
}
return new AbstractExpression("cos", Position.PREFIX, expressions) {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public double evaluate(Context context) {
return FastMath.cos(getExpressions().get(0).evaluate(context));
@@ -344,7 +344,7 @@ public double evaluate(Context context) {
}
private static class CoshExpressionDescriptor extends AbstractExpressionDescriptor {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public CoshExpressionDescriptor() {
@@ -358,7 +358,7 @@ public Expression createExpression(Expression... expressions) throws ExpressionI
" argument.");
}
return new AbstractExpression("cosh", Position.PREFIX, expressions) {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public double evaluate(Context context) {
return FastMath.cosh(getExpressions().get(0).evaluate(context));
@@ -368,7 +368,7 @@ public double evaluate(Context context) {
}
private static class AcosExpressionDescriptor extends AbstractExpressionDescriptor {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public AcosExpressionDescriptor() {
@@ -382,7 +382,7 @@ public Expression createExpression(Expression... expressions) throws ExpressionI
" argument.");
}
return new AbstractExpression("acos", Position.PREFIX, expressions) {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public double evaluate(Context context) {
return FastMath.acos(getExpressions().get(0).evaluate(context));
@@ -396,7 +396,7 @@ public double evaluate(Context context) {
* Flooor.
*/
private static class FloorExpressionDescriptor extends AbstractExpressionDescriptor {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public FloorExpressionDescriptor() {
@@ -410,7 +410,7 @@ public Expression createExpression(Expression... expressions) throws ExpressionI
" argument.");
}
return new AbstractExpression("floor", Position.PREFIX, expressions) {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public double evaluate(Context context) {
return FastMath.floor(getExpressions().get(0).evaluate(context));
@@ -423,7 +423,7 @@ public double evaluate(Context context) {
* Flooor.
*/
private static class AbsoluteValueExpressionDescriptor extends AbstractExpressionDescriptor {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public AbsoluteValueExpressionDescriptor() {
@@ -437,7 +437,7 @@ public Expression createExpression(Expression... expressions) throws ExpressionI
" argument.");
}
return new AbstractExpression("abs", Position.PREFIX, expressions) {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public double evaluate(Context context) {
return FastMath.abs(getExpressions().get(0).evaluate(context));
@@ -447,7 +447,7 @@ public double evaluate(Context context) {
}
private static class Log10ExpressionDescriptor extends AbstractExpressionDescriptor {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public Log10ExpressionDescriptor() {
@@ -461,7 +461,7 @@ public Expression createExpression(Expression... expressions) throws ExpressionI
" argument.");
}
return new AbstractExpression("log10", Position.PREFIX, expressions) {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public double evaluate(Context context) {
return FastMath.log10(getExpressions().get(0).evaluate(context));
@@ -475,7 +475,7 @@ public double evaluate(Context context) {
* Multiplication.
*/
private static class MultiplicationExpressionDescriptor extends AbstractExpressionDescriptor {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public MultiplicationExpressionDescriptor() {
@@ -488,7 +488,7 @@ public Expression createExpression(Expression... expressions) throws ExpressionI
throw new ExpressionInitializationException("Must have at least two arguments.");
}
return new AbstractExpression("*", Position.BOTH, expressions) {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public double evaluate(Context context) {
double value = 1.0;
@@ -506,7 +506,7 @@ public double evaluate(Context context) {
* Multiplication.
*/
private static class DivisionExpressionDescriptor extends AbstractExpressionDescriptor {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public DivisionExpressionDescriptor() {
@@ -519,7 +519,7 @@ public Expression createExpression(Expression... expressions) throws ExpressionI
throw new ExpressionInitializationException("Must have two arguments.");
}
return new AbstractExpression("/", Position.BOTH, expressions) {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public double evaluate(Context context) {
return getExpressions().get(0).evaluate(context)
@@ -534,7 +534,7 @@ public double evaluate(Context context) {
* Natural log.
*/
private static class NaturalLogExpressionDescriptor extends AbstractExpressionDescriptor {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public NaturalLogExpressionDescriptor() {
@@ -548,7 +548,7 @@ public Expression createExpression(Expression... expressions) throws ExpressionI
" argument.");
}
return new AbstractExpression("ln", Position.PREFIX, expressions) {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public double evaluate(Context context) {
return FastMath.log(getExpressions().get(0).evaluate(context));
@@ -561,7 +561,7 @@ public double evaluate(Context context) {
* Random value.
*/
private static class RandomExpressionDescriptor extends AbstractExpressionDescriptor {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public RandomExpressionDescriptor() {
@@ -574,7 +574,7 @@ public Expression createExpression(Expression... expressions) throws ExpressionI
throw new ExpressionInitializationException("Random must have no arguments.");
}
return new AbstractExpression("random", Position.PREFIX, expressions) {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public double evaluate(Context context) {
return FastMath.random();
@@ -587,7 +587,7 @@ public double evaluate(Context context) {
* Round expression.
*/
private static class RoundExpressionDescriptor extends AbstractExpressionDescriptor {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public RoundExpressionDescriptor() {
@@ -601,7 +601,7 @@ public Expression createExpression(Expression... expressions) throws ExpressionI
" argument.");
}
return new AbstractExpression("round", Position.PREFIX, expressions) {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public double evaluate(Context context) {
return FastMath.round(getExpressions().get(0).evaluate(context));
@@ -615,7 +615,7 @@ public double evaluate(Context context) {
* Tangent expression.
*/
private static class TanExpressionDescriptor extends AbstractExpressionDescriptor {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public TanExpressionDescriptor() {
@@ -629,7 +629,7 @@ public Expression createExpression(Expression... expressions) throws ExpressionI
" argument.");
}
return new AbstractExpression("tan", Position.PREFIX, expressions) {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public double evaluate(Context context) {
return FastMath.tan(getExpressions().get(0).evaluate(context));
@@ -639,7 +639,7 @@ public double evaluate(Context context) {
}
private static class TanhExpressionDescriptor extends AbstractExpressionDescriptor {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public TanhExpressionDescriptor() {
@@ -653,7 +653,7 @@ public Expression createExpression(Expression... expressions) throws ExpressionI
" argument.");
}
return new AbstractExpression("tanh", Position.PREFIX, expressions) {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public double evaluate(Context context) {
return FastMath.tanh(getExpressions().get(0).evaluate(context));
@@ -663,7 +663,7 @@ public double evaluate(Context context) {
}
private static class AtanExpressionDescriptor extends AbstractExpressionDescriptor {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public AtanExpressionDescriptor() {
@@ -677,7 +677,7 @@ public Expression createExpression(Expression... expressions) throws ExpressionI
" argument.");
}
return new AbstractExpression("atan", Position.PREFIX, expressions) {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public double evaluate(Context context) {
return FastMath.atan(getExpressions().get(0).evaluate(context));
@@ -687,7 +687,7 @@ public double evaluate(Context context) {
}
private static class LogisticExpressionDescriptor extends AbstractExpressionDescriptor {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public LogisticExpressionDescriptor() {
@@ -701,7 +701,7 @@ public Expression createExpression(Expression... expressions) throws ExpressionI
" argument.");
}
return new AbstractExpression("logistic", Position.PREFIX, expressions) {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public double evaluate(Context context) {
double t = getExpressions().get(0).evaluate(context);
@@ -715,7 +715,7 @@ public double evaluate(Context context) {
* Square Root.
*/
private static class SquareRootExpressionDescriptor extends AbstractExpressionDescriptor {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public SquareRootExpressionDescriptor() {
@@ -729,7 +729,7 @@ public Expression createExpression(Expression... expressions) throws ExpressionI
" argument.");
}
return new AbstractExpression("sqrt", Position.PREFIX, expressions) {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public double evaluate(Context context) {
return FastMath.sqrt(getExpressions().get(0).evaluate(context));
@@ -742,7 +742,7 @@ public double evaluate(Context context) {
* Sine expression.
*/
private static class SinExpressionDescriptor extends AbstractExpressionDescriptor {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public SinExpressionDescriptor() {
@@ -756,7 +756,7 @@ public Expression createExpression(Expression... expressions) throws ExpressionI
" argument.");
}
return new AbstractExpression("sin", Position.PREFIX, expressions) {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public double evaluate(Context context) {
return FastMath.sin(getExpressions().get(0).evaluate(context));
@@ -766,7 +766,7 @@ public double evaluate(Context context) {
}
private static class SinhExpressionDescriptor extends AbstractExpressionDescriptor {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public SinhExpressionDescriptor() {
@@ -780,7 +780,7 @@ public Expression createExpression(Expression... expressions) throws ExpressionI
" argument.");
}
return new AbstractExpression("sinh", Position.PREFIX, expressions) {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public double evaluate(Context context) {
return FastMath.sinh(getExpressions().get(0).evaluate(context));
@@ -790,7 +790,7 @@ public double evaluate(Context context) {
}
private static class AsinExpressionDescriptor extends AbstractExpressionDescriptor {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public AsinExpressionDescriptor() {
@@ -804,7 +804,7 @@ public Expression createExpression(Expression... expressions) throws ExpressionI
" argument.");
}
return new AbstractExpression("asin", Position.PREFIX, expressions) {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public double evaluate(Context context) {
return FastMath.asin(getExpressions().get(0).evaluate(context));
@@ -819,7 +819,7 @@ public double evaluate(Context context) {
* @author Tyler Gibson
*/
private static class PowExpressionDescriptor extends AbstractExpressionDescriptor {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public PowExpressionDescriptor() {
@@ -834,7 +834,7 @@ public Expression createExpression(Expression... expressions) throws ExpressionI
}
return new AbstractExpression("pow", Position.PREFIX, expressions) {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public double evaluate(Context context) {
Expression exp1 = getExpressions().get(0);
@@ -847,7 +847,7 @@ public double evaluate(Context context) {
}
private static class PowExpressionDescriptor2 extends AbstractExpressionDescriptor {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public PowExpressionDescriptor2() {
@@ -862,7 +862,7 @@ public Expression createExpression(Expression... expressions) throws ExpressionI
}
return new AbstractExpression("^", Position.INFIX, expressions) {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public double evaluate(Context context) {
Expression exp1 = getExpressions().get(0);
@@ -875,7 +875,7 @@ public double evaluate(Context context) {
}
private static class ExpExpressionDescriptor extends AbstractExpressionDescriptor {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public ExpExpressionDescriptor() {
super("Exponential", "exp", Position.PREFIX, false);
@@ -889,7 +889,7 @@ public Expression createExpression(Expression... expressions) throws ExpressionI
}
return new AbstractExpression("exp", Position.PREFIX, expressions) {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public double evaluate(Context context) {
Expression exp1 = getExpressions().get(0);
@@ -900,7 +900,7 @@ public double evaluate(Context context) {
}
private static class MaxExpressionDescriptor extends AbstractExpressionDescriptor {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public MaxExpressionDescriptor() {
@@ -913,7 +913,7 @@ public Expression createExpression(Expression... expressions) throws ExpressionI
throw new ExpressionInitializationException("max must have two or more arguments.");
}
return new AbstractExpression("max", Position.PREFIX, expressions) {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public double evaluate(Context context) {
double max = getExpressions().get(0).evaluate(context);
@@ -930,7 +930,7 @@ public double evaluate(Context context) {
}
private static class MinExpressionDescriptor extends AbstractExpressionDescriptor {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public MinExpressionDescriptor() {
@@ -943,7 +943,7 @@ public Expression createExpression(Expression... expressions) throws ExpressionI
throw new ExpressionInitializationException("min must have two or more arguments.");
}
return new AbstractExpression("min", Position.PREFIX, expressions) {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public double evaluate(Context context) {
double min = getExpressions().get(0).evaluate(context);
@@ -960,7 +960,7 @@ public double evaluate(Context context) {
}
private static class ChiSquareExpressionDescriptor extends AbstractExpressionDescriptor {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public ChiSquareExpressionDescriptor() {
super("Chi Square", "ChiSquare", Position.PREFIX, false);
@@ -974,7 +974,7 @@ public Expression createExpression(Expression... expressions) throws ExpressionI
}
return new AbstractExpression("ChiSquare", Position.PREFIX, expressions) {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public double evaluate(Context context) {
RandomGenerator randomGenerator = RandomUtil.getInstance().getRandomGenerator();
@@ -993,7 +993,7 @@ public RealDistribution getRealDistribution(Context context) {
}
private static class GammaExpressionDescriptor extends AbstractExpressionDescriptor {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public GammaExpressionDescriptor() {
super("Gamma", "Gamma", Position.PREFIX, false);
@@ -1007,7 +1007,7 @@ public Expression createExpression(Expression... expressions) throws ExpressionI
}
return new AbstractExpression("Gamma", Position.PREFIX, expressions) {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public double evaluate(Context context) {
RandomGenerator randomGenerator = RandomUtil.getInstance().getRandomGenerator();
@@ -1028,7 +1028,7 @@ public RealDistribution getRealDistribution(Context context) {
}
private static class BetaExpressionDescriptor extends AbstractExpressionDescriptor {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public BetaExpressionDescriptor() {
super("Beta", "Beta", Position.PREFIX, false);
@@ -1042,7 +1042,7 @@ public Expression createExpression(Expression... expressions) throws ExpressionI
}
return new AbstractExpression("Beta", Position.PREFIX, expressions) {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public double evaluate(Context context) {
RandomGenerator randomGenerator = RandomUtil.getInstance().getRandomGenerator();
@@ -1062,7 +1062,7 @@ public RealDistribution getRealDistribution(Context context) {
}
private static class CauchyExpressionDescriptor extends AbstractExpressionDescriptor {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public CauchyExpressionDescriptor() {
super("Cauchy", "Cauchy", Position.PREFIX, false);
@@ -1076,7 +1076,7 @@ public Expression createExpression(Expression... expressions) throws ExpressionI
}
return new AbstractExpression("Cauchy", Position.PREFIX, expressions) {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public double evaluate(Context context) {
RandomGenerator randomGenerator = RandomUtil.getInstance().getRandomGenerator();
@@ -1097,7 +1097,7 @@ public RealDistribution getRealDistribution(Context context) {
private static class FExpressionDescriptor extends AbstractExpressionDescriptor {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public FExpressionDescriptor() {
super("FDist", "FDist", Position.PREFIX, false);
@@ -1111,7 +1111,7 @@ public Expression createExpression(Expression... expressions) throws ExpressionI
}
return new AbstractExpression("FDist", Position.PREFIX, expressions) {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public double evaluate(Context context) {
RandomGenerator randomGenerator = RandomUtil.getInstance().getRandomGenerator();
@@ -1131,7 +1131,7 @@ public RealDistribution getRealDistribution(Context context) {
}
private static class GumbelExpressionDescriptor extends AbstractExpressionDescriptor {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public GumbelExpressionDescriptor() {
super("Gumbel", "Gumbel", Position.PREFIX, false);
@@ -1145,7 +1145,7 @@ public Expression createExpression(Expression... expressions) throws ExpressionI
}
return new AbstractExpression("Gumbel", Position.PREFIX, expressions) {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public double evaluate(Context context) {
RandomGenerator randomGenerator = RandomUtil.getInstance().getRandomGenerator();
@@ -1165,7 +1165,7 @@ public RealDistribution getRealDistribution(Context context) {
}
private static class LaplaceExpressionDescriptor extends AbstractExpressionDescriptor {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public LaplaceExpressionDescriptor() {
super("Laplace", "Laplace", Position.PREFIX, false);
@@ -1179,7 +1179,7 @@ public Expression createExpression(Expression... expressions) throws ExpressionI
}
return new AbstractExpression("Laplace", Position.PREFIX, expressions) {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public double evaluate(Context context) {
RandomGenerator randomGenerator = RandomUtil.getInstance().getRandomGenerator();
@@ -1199,7 +1199,7 @@ public RealDistribution getRealDistribution(Context context) {
}
private static class LevyExpressionDescriptor extends AbstractExpressionDescriptor {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public LevyExpressionDescriptor() {
super("Levy", "Levy", Position.PREFIX, false);
@@ -1213,7 +1213,7 @@ public Expression createExpression(Expression... expressions) throws ExpressionI
}
return new AbstractExpression("Levy", Position.PREFIX, expressions) {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public double evaluate(Context context) {
RandomGenerator randomGenerator = RandomUtil.getInstance().getRandomGenerator();
@@ -1233,7 +1233,7 @@ public RealDistribution getRealDistribution(Context context) {
}
private static class NakagamiExpressionDescriptor extends AbstractExpressionDescriptor {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public NakagamiExpressionDescriptor() {
super("Nakagami", "Nakagami", Position.PREFIX, false);
@@ -1247,7 +1247,7 @@ public Expression createExpression(Expression... expressions) throws ExpressionI
}
return new AbstractExpression("Nakagami", Position.PREFIX, expressions) {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public double evaluate(Context context) {
RandomGenerator randomGenerator = RandomUtil.getInstance().getRandomGenerator();
@@ -1267,7 +1267,7 @@ public RealDistribution getRealDistribution(Context context) {
}
private static class ParetoExpressionDescriptor extends AbstractExpressionDescriptor {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public ParetoExpressionDescriptor() {
super("Pareto", "Pareto", Position.PREFIX, false);
@@ -1281,7 +1281,7 @@ public Expression createExpression(Expression... expressions) throws ExpressionI
}
return new AbstractExpression("Pareto", Position.PREFIX, expressions) {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public double evaluate(Context context) {
RandomGenerator randomGenerator = RandomUtil.getInstance().getRandomGenerator();
@@ -1301,7 +1301,7 @@ public RealDistribution getRealDistribution(Context context) {
}
private static class TriangularExpressionDescriptor extends AbstractExpressionDescriptor {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public TriangularExpressionDescriptor() {
super("Triangular", "Triangular", Position.PREFIX, false);
@@ -1315,7 +1315,7 @@ public Expression createExpression(Expression... expressions) throws ExpressionI
}
return new AbstractExpression("Triangular", Position.PREFIX, expressions) {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public double evaluate(Context context) {
RandomGenerator randomGenerator = RandomUtil.getInstance().getRandomGenerator();
@@ -1337,7 +1337,7 @@ public RealDistribution getRealDistribution(Context context) {
}
private static class UniformExpressionDescriptor extends AbstractExpressionDescriptor {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public UniformExpressionDescriptor() {
super("Uniform", "Uniform", Position.PREFIX, false);
@@ -1351,7 +1351,7 @@ public Expression createExpression(Expression... expressions) throws ExpressionI
}
return new AbstractExpression("Uniform", Position.PREFIX, expressions) {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public double evaluate(Context context) {
RandomGenerator randomGenerator = RandomUtil.getInstance().getRandomGenerator();
@@ -1371,7 +1371,7 @@ public RealDistribution getRealDistribution(Context context) {
}
private static class UExpressionDescriptor extends AbstractExpressionDescriptor {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public UExpressionDescriptor() {
super("Uniform", "U", Position.PREFIX, false);
@@ -1385,7 +1385,7 @@ public Expression createExpression(Expression... expressions) throws ExpressionI
}
return new AbstractExpression("Uniform", Position.PREFIX, expressions) {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public double evaluate(Context context) {
RandomGenerator randomGenerator = RandomUtil.getInstance().getRandomGenerator();
@@ -1405,7 +1405,7 @@ public RealDistribution getRealDistribution(Context context) {
}
private static class WeibullExpressionDescriptor extends AbstractExpressionDescriptor {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public WeibullExpressionDescriptor() {
super("Weibull", "Weibull", Position.PREFIX, false);
@@ -1419,7 +1419,7 @@ public Expression createExpression(Expression... expressions) throws ExpressionI
}
return new AbstractExpression("Weibull", Position.PREFIX, expressions) {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public double evaluate(Context context) {
RandomGenerator randomGenerator = RandomUtil.getInstance().getRandomGenerator();
@@ -1439,7 +1439,7 @@ public RealDistribution getRealDistribution(Context context) {
}
private static class PoissonExpressionDescriptor extends AbstractExpressionDescriptor {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public PoissonExpressionDescriptor() {
super("Poisson", "Poisson", Position.PREFIX, false);
@@ -1453,7 +1453,7 @@ public Expression createExpression(Expression... expressions) throws ExpressionI
}
return new AbstractExpression("Poisson", Position.PREFIX, expressions) {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public double evaluate(Context context) {
RandomGenerator randomGenerator = RandomUtil.getInstance().getRandomGenerator();
@@ -1477,7 +1477,7 @@ public IntegerDistribution getIntegerDistribution(Context context) {
}
private static class IndicatorExpressionDescriptor extends AbstractExpressionDescriptor {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public IndicatorExpressionDescriptor() {
super("Indicator", "Indicator", Position.PREFIX, false);
@@ -1491,7 +1491,7 @@ public Expression createExpression(Expression... expressions) throws ExpressionI
}
return new AbstractExpression("Indicator", Position.PREFIX, expressions) {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public double evaluate(Context context) {
Expression exp1 = getExpressions().get(0);
@@ -1506,7 +1506,7 @@ public double evaluate(Context context) {
}
private static class ExponentialExpressionDescriptor extends AbstractExpressionDescriptor {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public ExponentialExpressionDescriptor() {
super("ExponentialDist", "ExponentialDist", Position.PREFIX, false);
@@ -1520,7 +1520,7 @@ public Expression createExpression(Expression... expressions) throws ExpressionI
}
return new AbstractExpression("ExponentialDist", Position.PREFIX, expressions) {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public double evaluate(Context context) {
RandomGenerator randomGenerator = RandomUtil.getInstance().getRandomGenerator();
@@ -1548,7 +1548,7 @@ public RealDistribution getRealDistribution(Context context) {
// // "exp(Normal(0, 1))"
private static class LogNormalExpressionDescriptor extends AbstractExpressionDescriptor {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public LogNormalExpressionDescriptor() {
super("LogNormal", "LogNormal", Position.PREFIX, false);
@@ -1562,7 +1562,7 @@ public Expression createExpression(Expression... expressions) throws ExpressionI
}
return new AbstractExpression("LogNormal", Position.PREFIX, expressions) {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public double evaluate(Context context) {
RandomGenerator randomGenerator = RandomUtil.getInstance().getRandomGenerator();
@@ -1598,7 +1598,7 @@ public RealDistribution getRealDistribution(Context context) {
}
private static class NormalExpressionDescriptor extends AbstractExpressionDescriptor {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public NormalExpressionDescriptor() {
super("Normal", "Normal", Position.PREFIX, false);
@@ -1612,7 +1612,7 @@ public Expression createExpression(Expression... expressions) throws ExpressionI
}
return new AbstractExpression("Normal", Position.PREFIX, expressions) {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public double evaluate(Context context) {
RandomGenerator randomGenerator = RandomUtil.getInstance().getRandomGenerator();
@@ -1632,7 +1632,7 @@ public RealDistribution getRealDistribution(Context context) {
}
private static class TruncNormalExpressionDescriptor extends AbstractExpressionDescriptor {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public TruncNormalExpressionDescriptor() {
super("TruncNormal", "TruncNormal", Position.PREFIX, false);
@@ -1646,7 +1646,7 @@ public Expression createExpression(Expression... expressions) throws ExpressionI
}
return new AbstractExpression("TruncNormal", Position.PREFIX, expressions) {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public double evaluate(Context context) {
Expression exp1 = getExpressions().get(0);
@@ -1673,7 +1673,7 @@ public double evaluate(Context context) {
}
private static class NExpressionDescriptor extends AbstractExpressionDescriptor {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public NExpressionDescriptor() {
super("Normal", "N", Position.PREFIX, false);
@@ -1687,7 +1687,7 @@ public Expression createExpression(Expression... expressions) throws ExpressionI
}
return new AbstractExpression("N", Position.PREFIX, expressions) {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public double evaluate(Context context) {
RandomGenerator randomGenerator = RandomUtil.getInstance().getRandomGenerator();
@@ -1710,7 +1710,7 @@ public RealDistribution getRealDistribution(Context context) {
}
private static class DiscreteExpressionDescriptor extends AbstractExpressionDescriptor {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public DiscreteExpressionDescriptor() {
super("Discrete", "Discrete", Position.PREFIX, false);
@@ -1724,7 +1724,7 @@ public Expression createExpression(Expression... expressions) throws ExpressionI
}
return new AbstractExpression("Discrete", Position.PREFIX, expressions) {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public double evaluate(Context context) {
double[] p = new double[getExpressions().size()];
@@ -1772,7 +1772,7 @@ private double[] convert(double... p) {
// "0.3 * Normal(-2, 0.5) + 0.7 * Normal(2, 0.5)
private static class MixtureDescriptor extends AbstractExpressionDescriptor {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public MixtureDescriptor() {
super("Mixture", "Mixture", Position.PREFIX, false);
@@ -1786,7 +1786,7 @@ public Expression createExpression(Expression... expressions) throws ExpressionI
}
return new AbstractExpression("Mixture", Position.PREFIX, expressions) {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public double evaluate(Context context) {
List exp = getExpressions();
@@ -1827,7 +1827,7 @@ public double evaluate(Context context) {
}
private static class StudentTExpressionDescriptor extends AbstractExpressionDescriptor {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public StudentTExpressionDescriptor() {
super("StudentT", "StudentT", Position.PREFIX, false);
@@ -1841,7 +1841,7 @@ public Expression createExpression(Expression... expressions) throws ExpressionI
}
return new AbstractExpression("StudentT", Position.PREFIX, expressions) {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public double evaluate(Context context) {
RandomGenerator randomGenerator = RandomUtil.getInstance().getRandomGenerator();
@@ -1865,7 +1865,7 @@ public RealDistribution getRealDistribution(Context context) {
* Draws from the U(a1, b2) U U(a3, a4)...
*/
private static class SplitExpressionDescriptor extends AbstractExpressionDescriptor {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public SplitExpressionDescriptor() {
super("Split", "Split", Position.PREFIX, false);
@@ -1879,7 +1879,7 @@ public Expression createExpression(Expression... expressions) throws ExpressionI
}
return new AbstractExpression("Split", Position.PREFIX, expressions) {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public double evaluate(Context context) {
if (getExpressions().size() < 2) {
@@ -1930,7 +1930,7 @@ public double evaluate(Context context) {
* For boolean "and". Will return true if all sub-expressions evaluate to a non-zero value and false otherwise.
*/
private static class AndExpressionDescriptor extends AbstractExpressionDescriptor {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public AndExpressionDescriptor() {
@@ -1943,7 +1943,7 @@ public Expression createExpression(Expression... expressions) throws ExpressionI
throw new ExpressionInitializationException("Must have at least two arguments.");
}
return new AbstractExpression("AND", Position.PREFIX, expressions) {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public double evaluate(Context context) {
boolean allOnes = true;
@@ -1965,7 +1965,7 @@ public double evaluate(Context context) {
* For boolean "Or". Will return 1.0 if at least one of the sub-expressions is non-zero.
*/
private static class OrExpressionDescriptor extends AbstractExpressionDescriptor {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public OrExpressionDescriptor() {
super("Or", "OR", Position.PREFIX, true);
@@ -1976,7 +1976,7 @@ public Expression createExpression(Expression... expressions) throws ExpressionI
throw new ExpressionInitializationException("Must have at least two arguments.");
}
return new AbstractExpression("OR", Position.PREFIX, expressions) {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public double evaluate(Context context) {
for (Expression exp : getExpressions()) {
@@ -1994,7 +1994,7 @@ public double evaluate(Context context) {
* For boolean "Or". Will return 1.0 if at least one of the sub-expressions is non-zero.
*/
private static class XOrExpressionDescriptor extends AbstractExpressionDescriptor {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public XOrExpressionDescriptor() {
super("Exclusive or", "XOR", Position.PREFIX, false);
@@ -2005,7 +2005,7 @@ public Expression createExpression(Expression... expressions) throws ExpressionI
throw new ExpressionInitializationException("Must have two arguments.");
}
return new AbstractExpression("XOR", Position.PREFIX, expressions) {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public double evaluate(Context context) {
double first = getExpressions().get(0).evaluate(context);
@@ -2020,7 +2020,7 @@ public double evaluate(Context context) {
}
private static class LessThanExpressionDescriptor extends AbstractExpressionDescriptor {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public LessThanExpressionDescriptor() {
super("Less Than", "<", Position.BOTH, true);
@@ -2032,7 +2032,7 @@ public Expression createExpression(Expression... expressions) throws ExpressionI
}
return new AbstractExpression("<", Position.BOTH, expressions) {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public double evaluate(Context context) {
List expressions = getExpressions();
@@ -2045,7 +2045,7 @@ public double evaluate(Context context) {
}
private static class LessThanOrEqualExpressionDescriptor extends AbstractExpressionDescriptor {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public LessThanOrEqualExpressionDescriptor() {
super("Less Than Or Equals", "<=", Position.BOTH, true);
@@ -2057,7 +2057,7 @@ public Expression createExpression(Expression... expressions) throws ExpressionI
}
return new AbstractExpression("<=", Position.BOTH, expressions) {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public double evaluate(Context context) {
List expressions = getExpressions();
@@ -2070,7 +2070,7 @@ public double evaluate(Context context) {
}
private static class EqualsExpressionDescriptor extends AbstractExpressionDescriptor {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public EqualsExpressionDescriptor() {
super("Equals", "=", Position.BOTH, true);
@@ -2082,7 +2082,7 @@ public Expression createExpression(Expression... expressions) throws ExpressionI
}
return new AbstractExpression("=", Position.BOTH, expressions) {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public double evaluate(Context context) {
List expressions = getExpressions();
@@ -2095,7 +2095,7 @@ public double evaluate(Context context) {
}
private static class GreaterThanExpressionDescriptor extends AbstractExpressionDescriptor {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public GreaterThanExpressionDescriptor() {
super("Greater Than", ">", Position.BOTH, true);
@@ -2107,7 +2107,7 @@ public Expression createExpression(Expression... expressions) throws ExpressionI
}
return new AbstractExpression("<", Position.BOTH, expressions) {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public double evaluate(Context context) {
List expressions = getExpressions();
@@ -2120,7 +2120,7 @@ public double evaluate(Context context) {
}
private static class GreaterThanOrEqualExpressionDescriptor extends AbstractExpressionDescriptor {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public GreaterThanOrEqualExpressionDescriptor() {
super("Greater Than Or Equals", ">=", Position.BOTH, true);
@@ -2132,7 +2132,7 @@ public Expression createExpression(Expression... expressions) throws ExpressionI
}
return new AbstractExpression("<", Position.BOTH, expressions) {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public double evaluate(Context context) {
List expressions = getExpressions();
@@ -2145,7 +2145,7 @@ public double evaluate(Context context) {
}
private static class IfExpressionDescriptor extends AbstractExpressionDescriptor {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public IfExpressionDescriptor() {
super("If", "IF", Position.PREFIX, true);
@@ -2157,7 +2157,7 @@ public Expression createExpression(Expression... expressions) throws ExpressionI
}
return new AbstractExpression("IF", Position.BOTH, expressions) {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public double evaluate(Context context) {
List expressions = getExpressions();
@@ -2171,7 +2171,7 @@ public double evaluate(Context context) {
}
private static class NewExpressionDescriptor extends AbstractExpressionDescriptor {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public NewExpressionDescriptor() {
super("New Parameter", "NEW", Position.PREFIX, true);
@@ -2187,7 +2187,7 @@ public Expression createExpression(Expression... expressions) throws ExpressionI
}
return new AbstractExpression("NEW", Position.BOTH, expressions) {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public double evaluate(Context context) {
return Double.NaN;
@@ -2197,7 +2197,7 @@ public double evaluate(Context context) {
}
private static class NewExpressionDescriptor2 extends AbstractExpressionDescriptor {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public NewExpressionDescriptor2() {
super("New Parameter", "new", Position.PREFIX, true);
@@ -2213,7 +2213,7 @@ public Expression createExpression(Expression... expressions) throws ExpressionI
}
return new AbstractExpression("new", Position.BOTH, expressions) {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public double evaluate(Context context) {
return Double.NaN;
@@ -2223,7 +2223,7 @@ public double evaluate(Context context) {
}
private static class TSumExpressionDescriptor extends AbstractExpressionDescriptor {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public TSumExpressionDescriptor() {
super("Template Sum", "TSUM", Position.PREFIX, true);
@@ -2235,7 +2235,7 @@ public Expression createExpression(Expression... expressions) throws ExpressionI
}
return new AbstractExpression("TSUM", Position.PREFIX, expressions) {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public double evaluate(Context context) {
return Double.NaN;
@@ -2245,7 +2245,7 @@ public double evaluate(Context context) {
}
private static class TSumExpressionDescriptor2 extends AbstractExpressionDescriptor {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public TSumExpressionDescriptor2() {
super("Template Sum", "tsum", Position.PREFIX, true);
@@ -2257,7 +2257,7 @@ public Expression createExpression(Expression... expressions) throws ExpressionI
}
return new AbstractExpression("tsum", Position.PREFIX, expressions) {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public double evaluate(Context context) {
return Double.NaN;
@@ -2267,7 +2267,7 @@ public double evaluate(Context context) {
}
private static class TProductExpressionDescriptor extends AbstractExpressionDescriptor {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public TProductExpressionDescriptor() {
super("Template Product", "TPROD", Position.PREFIX, true);
@@ -2279,7 +2279,7 @@ public Expression createExpression(Expression... expressions) throws ExpressionI
}
return new AbstractExpression("TPROD", Position.PREFIX, expressions) {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public double evaluate(Context context) {
return Double.NaN;
@@ -2289,7 +2289,7 @@ public double evaluate(Context context) {
}
private static class TProductExpressionDescriptor2 extends AbstractExpressionDescriptor {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public TProductExpressionDescriptor2() {
super("Template Product", "tprod", Position.PREFIX, true);
@@ -2301,7 +2301,7 @@ public Expression createExpression(Expression... expressions) throws ExpressionI
}
return new AbstractExpression("tprod", Position.PREFIX, expressions) {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public double evaluate(Context context) {
return Double.NaN;
@@ -2314,7 +2314,7 @@ public double evaluate(Context context) {
//First term should be a random draw that will be used to select a category index based on the (un-normalized)
//weights given in the rest of the terms
private static class DiscErrorExpressionDescriptor extends AbstractExpressionDescriptor {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public DiscErrorExpressionDescriptor() {
super("DiscError", "DiscError", Position.PREFIX, false);
@@ -2328,7 +2328,7 @@ public Expression createExpression(Expression... expressions) throws ExpressionI
}
return new AbstractExpression("DiscError", Position.PREFIX, expressions) {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public double evaluate(Context context) {
double[] p = new double[getExpressions().size() - 1];
@@ -2380,7 +2380,7 @@ private double[] convert(double... p) {
//the first term is an index (non-negative integer) that tells the expression which of the rest of the terms to
//return
private static class SwitchExpressionDescriptor extends AbstractExpressionDescriptor {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public SwitchExpressionDescriptor() {
super("Switch", "Switch", Position.PREFIX, true);
@@ -2393,7 +2393,7 @@ public Expression createExpression(Expression... expressions) throws ExpressionI
}
return new AbstractExpression("Switch", Position.BOTH, expressions) {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
public double evaluate(Context context) {
List expressions = getExpressions();
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/calculator/expression/VariableExpression.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/calculator/expression/VariableExpression.java
index 7c123fbe74..4f8fae696e 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/calculator/expression/VariableExpression.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/calculator/expression/VariableExpression.java
@@ -33,7 +33,7 @@
* @author Tyler Gibson
*/
public class VariableExpression implements Expression {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
/**
* The variable that is being evaluated.
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/calibration/DataForCalibrationRfci.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/calibration/DataForCalibrationRfci.java
index 5f45f46990..b5e4916a5c 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/calibration/DataForCalibrationRfci.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/calibration/DataForCalibrationRfci.java
@@ -2,13 +2,12 @@
import edu.cmu.tetrad.data.ContinuousVariable;
import edu.cmu.tetrad.data.DataSet;
-import edu.cmu.tetrad.data.DataUtils;
+import edu.cmu.tetrad.data.DataTransforms;
import edu.cmu.tetrad.graph.*;
import edu.cmu.tetrad.search.BFci;
import edu.cmu.tetrad.search.Rfci;
import edu.cmu.tetrad.search.score.SemBicScore;
import edu.cmu.tetrad.search.test.IndTestFisherZ;
-import edu.cmu.tetrad.search.utils.GraphSearchUtils;
import edu.cmu.tetrad.sem.LargeScaleSimulation;
import edu.cmu.tetrad.util.MillisecondTimes;
import org.apache.commons.math3.util.FastMath;
@@ -111,7 +110,7 @@ public static void main(String[] args) throws IOException {
//
// Graph truePag = dagToPag.convert();
- Graph truePag = GraphSearchUtils.dagToPag(dag);
+ Graph truePag = GraphTransforms.dagToPag(dag);
System.out.println("true PAG construction Done!");
@@ -123,7 +122,7 @@ public static void main(String[] args) throws IOException {
DataSet data = simulator.simulateDataReducedForm(numCases);
// To remove the columns related to latent variables from dataset
- data = DataUtils.restrictToMeasured(data);
+ data = DataTransforms.restrictToMeasured(data);
System.out.println("Data simulation done");
System.out.println("Covariance matrix done");
@@ -350,7 +349,7 @@ public Graph makeDAG(int numVars, double edgesPerNode, int numLatentConfounders)
}
public DataSet bootStrapSampling(DataSet data, int bootsrapSampleSize) {
- return DataUtils.getBootstrapSample(data, bootsrapSampleSize);
+ return DataTransforms.getBootstrapSample(data, bootsrapSampleSize);
}
public Graph learnBNRFCI(DataSet bootstrapSample, int depth, Graph truePag) {
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/classify/ClassifierBayesUpdaterDiscrete.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/classify/ClassifierBayesUpdaterDiscrete.java
index 8f77ee97b2..bd4c5d2870 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/classify/ClassifierBayesUpdaterDiscrete.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/classify/ClassifierBayesUpdaterDiscrete.java
@@ -47,7 +47,7 @@
*/
public final class ClassifierBayesUpdaterDiscrete
implements ClassifierDiscrete, TetradSerializable {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
/**
* The BayesIm instance used to create an updater. Supplied as an argument to the constructor.
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/classify/ClassifierMbDiscrete.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/classify/ClassifierMbDiscrete.java
index da923d4659..2cfee5c690 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/classify/ClassifierMbDiscrete.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/classify/ClassifierMbDiscrete.java
@@ -80,9 +80,9 @@ public ClassifierMbDiscrete(String trainPath, String testPath, String targetStri
TetradLogger.getInstance().log("info", s);
DataSet train = SimpleDataLoader.loadContinuousData(new File(trainPath), "//", '\"',
- "*", true, Delimiter.TAB);
+ "*", true, Delimiter.TAB, false);
DataSet test = SimpleDataLoader.loadContinuousData(new File(testPath), "//", '\"',
- "*", true, Delimiter.TAB);
+ "*", true, Delimiter.TAB, false);
double alpha = Double.parseDouble(alphaString);
int depth = Integer.parseInt(depthString);
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/AbstractVariable.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/AbstractVariable.java
index fd7a7ddd34..34789947ee 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/AbstractVariable.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/AbstractVariable.java
@@ -34,8 +34,11 @@
*/
public abstract class AbstractVariable implements Variable {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
+ /**
+ * The last ID assigned to a variable.
+ */
public static int LAST_ID;
/**
@@ -94,20 +97,20 @@ public final void setName(String name) {
/**
* Checks to see whether the passed value is an acceptable value for
- * this variable. For AbstractVariable, this method always
- * returns true. Subclasses should override
- * checkValue() in order to provide for subclass-specific value
+ * this variable. For AbstractVariable, this method always
+ * returns true. Subclasses should override
+ * checkValue() in order to provide for subclass-specific value
* checking. The value should pass the test if it can be converted into an equivalent object of the correct class
* type (see
- * getValueClass()) for this variable; otherwise, it should fail. In
- * general, checkValue() should not fail a value for simply not being an instance of a particular class.
+ * getValueClass()) for this variable; otherwise, it should fail. In
+ * general, checkValue() should not fail a value for simply not being an instance of a particular class.
* Since this method is not
- * static, subclasses may (but need not) provide for
+ * static, subclasses may (but need not) provide for
* instance-specific value checking.
*
* @param value a value
- * @return true if the value is an acceptable value for
- * this variable, and false otherwise
+ * @return true if the value is an acceptable value for
+ * this variable, and false otherwise
*/
public boolean checkValue(Object value) {
return true;
@@ -122,57 +125,57 @@ public String toString() {
public abstract Node like(String name);
- @Override
- public int compareTo(Node node) {
- String node1 = getName();
- String node2 = node.getName();
-
- boolean isAlpha1 = Node.ALPHA.matcher(node1).matches();
- boolean isAlpha2 = Node.ALPHA.matcher(node2).matches();
- boolean isAlphaNum1 = Node.ALPHA_NUM.matcher(node1).matches();
- boolean isAlphaNum2 = Node.ALPHA_NUM.matcher(node2).matches();
- boolean isLag1 = Node.LAG.matcher(node1).matches();
- boolean isLag2 = Node.LAG.matcher(node2).matches();
-
- if (isAlpha1) {
- if (isLag2) {
- return -1;
- }
- } else if (isAlphaNum1) {
- if (isAlphaNum2) {
- String s1 = node1.replaceAll("\\d+", "");
- String s2 = node2.replaceAll("\\d+", "");
- if (s1.equals(s2)) {
- String n1 = node1.replaceAll("\\D+", "");
- String n2 = node2.replaceAll("\\D+", "");
-
- return Integer.valueOf(n1).compareTo(Integer.valueOf(n2));
- } else {
- return s1.compareTo(s2);
- }
- } else if (isLag2) {
- return -1;
- }
- } else if (isLag1) {
- if (isAlpha2 || isAlphaNum2) {
- return 1;
- } else if (isLag2) {
- String l1 = node1.replaceAll(":", "");
- String l2 = node2.replaceAll(":", "");
- String s1 = l1.replaceAll("\\d+", "");
- String s2 = l2.replaceAll("\\d+", "");
- if (s1.equals(s2)) {
- String n1 = l1.replaceAll("\\D+", "");
- String n2 = l2.replaceAll("\\D+", "");
-
- return Integer.valueOf(n1).compareTo(Integer.valueOf(n2));
- } else {
- return s1.compareTo(s2);
- }
- }
- }
-
- return node1.compareTo(node2);
- }
+// @Override
+// public int compareTo(Node node) {
+// String node1 = getName();
+// String node2 = node.getName();
+//
+// boolean isAlpha1 = Node.ALPHA.matcher(node1).matches();
+// boolean isAlpha2 = Node.ALPHA.matcher(node2).matches();
+// boolean isAlphaNum1 = Node.ALPHA_NUM.matcher(node1).matches();
+// boolean isAlphaNum2 = Node.ALPHA_NUM.matcher(node2).matches();
+// boolean isLag1 = Node.LAG.matcher(node1).matches();
+// boolean isLag2 = Node.LAG.matcher(node2).matches();
+//
+// if (isAlpha1) {
+// if (isLag2) {
+// return -1;
+// }
+// } else if (isAlphaNum1) {
+// if (isAlphaNum2) {
+// String s1 = node1.replaceAll("\\d+", "");
+// String s2 = node2.replaceAll("\\d+", "");
+// if (s1.equals(s2)) {
+// String n1 = node1.replaceAll("\\D+", "");
+// String n2 = node2.replaceAll("\\D+", "");
+//
+// return Integer.valueOf(n1).compareTo(Integer.valueOf(n2));
+// } else {
+// return s1.compareTo(s2);
+// }
+// } else if (isLag2) {
+// return -1;
+// }
+// } else if (isLag1) {
+// if (isAlpha2 || isAlphaNum2) {
+// return 1;
+// } else if (isLag2) {
+// String l1 = node1.replaceAll(":", "");
+// String l2 = node2.replaceAll(":", "");
+// String s1 = l1.replaceAll("\\d+", "");
+// String s2 = l2.replaceAll("\\d+", "");
+// if (s1.equals(s2)) {
+// String n1 = l1.replaceAll("\\D+", "");
+// String n2 = l2.replaceAll("\\D+", "");
+//
+// return Integer.valueOf(n1).compareTo(Integer.valueOf(n2));
+// } else {
+// return s1.compareTo(s2);
+// }
+// }
+// }
+//
+// return node1.compareTo(node2);
+// }
}
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/AndersonDarlingTest.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/AndersonDarlingTest.java
index ed493930e1..3d58112c66 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/AndersonDarlingTest.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/AndersonDarlingTest.java
@@ -61,6 +61,8 @@ public class AndersonDarlingTest {
/**
* Constructs an Anderson-Darling test for the given column of data.
+ *
+ * @param data the column of data to be analyzed.
*/
public AndersonDarlingTest(double[] data) {
this.data = data;
@@ -68,6 +70,8 @@ public AndersonDarlingTest(double[] data) {
}
/**
+ * Constructs an Anderson-Darling test for the given column of data.
+ *
* @return the A^2 statistic.
*/
public double getASquared() {
@@ -75,6 +79,8 @@ public double getASquared() {
}
/**
+ * Constructs an Anderson-Darling test for the given column of data.
+ *
* @return the A^2* statistic, which is the A^2 statistic adjusted heuristically for sample size.
*/
public double getASquaredStar() {
@@ -82,6 +88,8 @@ public double getASquaredStar() {
}
/**
+ * Constructs an Anderson-Darling test for the given column of data.
+ *
* @return the p value of the A^2* statistic, which is interpolated using exponential functions.
*/
public double getP() {
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/BoxDataSet.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/BoxDataSet.java
index 786568026a..450149b03c 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/BoxDataSet.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/BoxDataSet.java
@@ -55,7 +55,7 @@
* Knowledge may be associated with the data set, using the
* setKnowledge
method. This knowledge is not used internally to
* the data set, but it may be retrieved by algorithms and used.
- *
+ *
*
* @author josephramsey
* @see edu.cmu.tetrad.data.Variable
@@ -63,7 +63,7 @@
*/
public final class BoxDataSet implements DataSet {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
/**
* Case ID's. These are strings associated with some or all of the cases of the dataset.
*
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/ByteDataBox.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/ByteDataBox.java
index 85314063c8..3e777c5990 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/ByteDataBox.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/ByteDataBox.java
@@ -30,7 +30,7 @@
* Stores a 2D array of byte data. Note that the missing value marker for this box is -99.
*/
public class ByteDataBox implements DataBox {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
/**
* The stored byte data.
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/Clusters.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/Clusters.java
index 67b6d108c3..4d262cbba2 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/Clusters.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/Clusters.java
@@ -35,7 +35,7 @@
* @author Ricardo Silva
*/
public final class Clusters implements TetradSerializable {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
/**
* This is used to store information on pure measurement models (when the graph is a measurement/structural model).
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/ContinuousDiscretizationSpec.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/ContinuousDiscretizationSpec.java
index e40ed1bbd5..26ef62bc60 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/ContinuousDiscretizationSpec.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/ContinuousDiscretizationSpec.java
@@ -43,7 +43,7 @@ public final class ContinuousDiscretizationSpec implements TetradSerializable, D
public static final int EVENLY_DISTRIBUTED_VALUES = 1;
public static final int EVENLY_DISTRIBUTED_INTERVALS = 2;
public static final int NONE = 3;
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
/**
* Breakpoints, for continuous data.
*
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/ContinuousVariable.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/ContinuousVariable.java
index b1ed8371ca..24ab2aa194 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/ContinuousVariable.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/ContinuousVariable.java
@@ -37,11 +37,11 @@
* @author Willie Wheeler 07/99
* @author josephramsey modifications 12/00
*/
-public final class ContinuousVariable extends AbstractVariable {
+public final class ContinuousVariable extends AbstractVariable implements Variable {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
- /**
+/**
* This is the value which represents missing data in data columns for this variable.
*/
private static final double MISSING_VALUE = Double.NaN;
@@ -90,7 +90,7 @@ public ContinuousVariable(ContinuousVariable variable) {
this.nodeType = variable.nodeType;
this.centerX = variable.centerX;
this.centerY = variable.centerY;
- this.nodeVariableType = getNodeVariableType();
+ this.nodeVariableType = variable.nodeVariableType;
}
/**
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/CorrelationMatrix.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/CorrelationMatrix.java
index 25ce7291aa..1035d5f6a8 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/CorrelationMatrix.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/CorrelationMatrix.java
@@ -37,7 +37,7 @@
* @author josephramsey
*/
public final class CorrelationMatrix extends CovarianceMatrix {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
/**
* Constructs a new correlation matrix using the covariances in the given covariance matrix.
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/CorrelationMatrixOnTheFly.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/CorrelationMatrixOnTheFly.java
index 6bb72ab86d..5224dff3e9 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/CorrelationMatrixOnTheFly.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/CorrelationMatrixOnTheFly.java
@@ -43,7 +43,7 @@
* @see CorrelationMatrix
*/
public class CorrelationMatrixOnTheFly implements ICovarianceMatrix {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
private final ICovarianceMatrix cov;
private boolean verbose;
/**
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/CovarianceMatrix.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/CovarianceMatrix.java
index 5579f363f1..81a3374627 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/CovarianceMatrix.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/CovarianceMatrix.java
@@ -40,7 +40,7 @@
* @see edu.cmu.tetrad.data.CorrelationMatrix
*/
public class CovarianceMatrix implements ICovarianceMatrix {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
/**
* The wrapped covariance matrix data.
*/
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/CovarianceMatrixOnTheFly.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/CovarianceMatrixOnTheFly.java
index 044cc81ec4..735eb7ca4e 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/CovarianceMatrixOnTheFly.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/CovarianceMatrixOnTheFly.java
@@ -45,7 +45,7 @@
* @see CorrelationMatrix
*/
public class CovarianceMatrixOnTheFly implements ICovarianceMatrix {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
private final double[] variances;
private boolean verbose = false;
/**
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/CovariancesDoubleForkJoin.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/CovariancesDoubleForkJoin.java
index 9bada02fdb..570ba61505 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/CovariancesDoubleForkJoin.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/CovariancesDoubleForkJoin.java
@@ -27,7 +27,7 @@
* @author Joseph D. Ramsey
*/
public class CovariancesDoubleForkJoin {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
private final int numOfCols;
private final double[][] covariances;
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/DataGraphUtils.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/DataGraphUtils.java
index af5844a17a..973a738f67 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/DataGraphUtils.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/DataGraphUtils.java
@@ -219,7 +219,7 @@ public static Graph randomMim(Graph graph, int numMeasurementsPerLatent,
}
if (arrangeGraph) {
- LayoutUtil.circleLayout(graph1);
+ LayoutUtil.defaultLayout(graph1);
LayoutUtil.fruchtermanReingoldLayout(graph1);
}
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/DataModelList.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/DataModelList.java
index 983562ebfc..f6d94141aa 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/DataModelList.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/DataModelList.java
@@ -38,7 +38,7 @@
public final class DataModelList extends AbstractList
implements DataModel {
- static final long serialVersionUID = 23L;
+ private static final long serialVersionUID = 23L;
/**
* The list of models.
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/DataTransforms.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/DataTransforms.java
new file mode 100644
index 0000000000..2462a1d3df
--- /dev/null
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/DataTransforms.java
@@ -0,0 +1,1035 @@
+package edu.cmu.tetrad.data;
+
+
+import cern.colt.list.DoubleArrayList;
+import edu.cmu.tetrad.graph.Node;
+import edu.cmu.tetrad.graph.NodeType;
+import edu.cmu.tetrad.util.Matrix;
+import edu.cmu.tetrad.util.RandomUtil;
+import edu.cmu.tetrad.util.StatUtils;
+import edu.cmu.tetrad.util.Vector;
+import org.apache.commons.math3.distribution.NormalDistribution;
+import org.apache.commons.math3.exception.OutOfRangeException;
+import org.apache.commons.math3.random.RandomGenerator;
+import org.apache.commons.math3.util.FastMath;
+
+import java.rmi.MarshalledObject;
+import java.util.*;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
+
+public class DataTransforms {
+
+
+ /**
+ * Log or unlog data
+ */
+ public static DataSet logData(DataSet dataSet, double a, boolean isUnlog, int base) {
+ Matrix data = dataSet.getDoubleData();
+ Matrix X = data.like();
+
+ for (int j = 0; j < data.getNumColumns(); j++) {
+ double[] x1Orig = Arrays.copyOf(data.getColumn(j).toArray(), data.getNumRows());
+ double[] x1 = Arrays.copyOf(data.getColumn(j).toArray(), data.getNumRows());
+
+ if (dataSet.getVariable(j) instanceof DiscreteVariable) {
+ X.assignColumn(j, new Vector(x1));
+ continue;
+ }
+
+ for (int i = 0; i < x1.length; i++) {
+ if (isUnlog) {
+ if (base == 0) {
+ x1[i] = FastMath.exp(x1Orig[i]) - a;
+ } else {
+ x1[i] = FastMath.pow(base, (x1Orig[i])) - a;
+ }
+ } else {
+ double log = FastMath.log(a + x1Orig[i]);
+ if (base == 0) {
+ x1[i] = log;
+ } else {
+ x1[i] = log / FastMath.log(base);
+ }
+ }
+ }
+
+ X.assignColumn(j, new Vector(x1));
+ }
+
+ return new BoxDataSet(new VerticalDoubleDataBox(X.transpose().toArray()), dataSet.getVariables());
+ }
+
+ public static List standardizeData(List dataSets) {
+ List outList = new ArrayList<>();
+
+ for (DataSet dataSet : dataSets) {
+ if (!(dataSet.isContinuous())) {
+ throw new IllegalArgumentException("Not a continuous data set: " + dataSet.getName());
+ }
+
+ Matrix data2 = standardizeData(dataSet.getDoubleData());
+
+ DataSet dataSet2 = new BoxDataSet(new VerticalDoubleDataBox(data2.transpose().toArray()), dataSet.getVariables());
+ outList.add(dataSet2);
+ }
+
+ return outList;
+ }
+
+ public static DataSet standardizeData(DataSet dataSet) {
+ List dataSets = Collections.singletonList(dataSet);
+ List outList = standardizeData(dataSets);
+ return outList.get(0);
+ }
+
+ public static List center(List dataList) {
+ List dataSets = new ArrayList<>(dataList);
+ List outList = new ArrayList<>();
+
+ for (DataSet model : dataSets) {
+ if (model == null) {
+ throw new NullPointerException("Missing dataset.");
+ }
+
+ if (!(model.isContinuous())) {
+ throw new IllegalArgumentException("Not a continuous data set: " + model.getName());
+ }
+
+ Matrix data2 = centerData(model.getDoubleData());
+ List list = model.getVariables();
+ List list2 = new ArrayList<>(list);
+
+ DataSet dataSet2 = new BoxDataSet(new VerticalDoubleDataBox(data2.transpose().toArray()), list2);
+ outList.add(dataSet2);
+ }
+
+ return outList;
+ }
+
+ public static DataSet discretize(DataSet dataSet, int numCategories, boolean variablesCopied) {
+ Discretizer discretizer = new Discretizer(dataSet);
+ discretizer.setVariablesCopied(variablesCopied);
+
+ for (Node node : dataSet.getVariables()) {
+// if (dataSet.getVariable(node.getNode()) instanceof ContinuousVariable) {
+ discretizer.equalIntervals(node, numCategories);
+// }
+ }
+
+ return discretizer.discretize();
+ }
+
+ public static DataSet convertNumericalDiscreteToContinuous(
+ DataSet dataSet) throws NumberFormatException {
+ List variables = new ArrayList<>();
+
+ for (Node variable : dataSet.getVariables()) {
+ if (variable instanceof ContinuousVariable) {
+ variables.add(variable);
+ } else {
+ variables.add(new ContinuousVariable(variable.getName()));
+ }
+ }
+
+ DataSet continuousData = new BoxDataSet(new VerticalDoubleDataBox(dataSet.getNumRows(), variables.size()), variables);
+
+ for (int j = 0; j < dataSet.getNumColumns(); j++) {
+ Node variable = dataSet.getVariable(j);
+
+ if (variable instanceof ContinuousVariable) {
+ for (int i = 0; i < dataSet.getNumRows(); i++) {
+ continuousData.setDouble(i, j, dataSet.getDouble(i, j));
+ }
+ } else {
+ DiscreteVariable discreteVariable = (DiscreteVariable) variable;
+
+ boolean allNumerical = true;
+
+ for (String cat : discreteVariable.getCategories()) {
+ try {
+ Double.parseDouble(cat);
+ } catch (NumberFormatException e) {
+ allNumerical = false;
+ break;
+ }
+ }
+
+
+ for (int i = 0; i < dataSet.getNumRows(); i++) {
+ int index = dataSet.getInt(i, j);
+ String catName = discreteVariable.getCategory(index);
+ double value;
+
+ if (catName.equals("*")) {
+ value = Double.NaN;
+ } else {
+ if (allNumerical) {
+ value = Double.parseDouble(catName);
+ } else {
+ value = index;
+ }
+ }
+
+ continuousData.setDouble(i, j, value);
+ }
+ }
+ }
+
+ return continuousData;
+ }
+
+ public static DataSet concatenate(DataSet dataSet1, DataSet dataSet2) {
+ List vars1 = dataSet1.getVariables();
+ List vars2 = dataSet2.getVariables();
+ Map varMap2 = new HashMap<>();
+ for (int i = 0; i < vars2.size(); i++) {
+ varMap2.put(vars2.get(i).getName(), i);
+ }
+ int rows1 = dataSet1.getNumRows();
+ int rows2 = dataSet2.getNumRows();
+ int cols1 = dataSet1.getNumColumns();
+
+ Matrix concatMatrix = new Matrix(rows1 + rows2, cols1);
+ Matrix matrix1 = dataSet1.getDoubleData();
+ Matrix matrix2 = dataSet2.getDoubleData();
+
+ for (int i = 0; i < vars1.size(); i++) {
+ int var2 = varMap2.get(vars1.get(i).getName());
+ for (int j = 0; j < rows1; j++) {
+ concatMatrix.set(j, i, matrix1.get(j, i));
+ }
+ for (int j = 0; j < rows2; j++) {
+ concatMatrix.set(j + rows1, i, matrix2.get(j, var2));
+ }
+ }
+
+ return new BoxDataSet(new VerticalDoubleDataBox(concatMatrix.transpose().toArray()), vars1);
+ }
+
+ public static DataSet concatenate(DataSet... dataSets) {
+ List _dataSets = new ArrayList<>();
+
+ Collections.addAll(_dataSets, dataSets);
+
+ return concatenate(_dataSets);
+ }
+
+ // Trying to optimize some.
+ public static DataSet concatenate(List dataSets) {
+ int totalSampleSize = 0;
+
+ for (DataSet dataSet : dataSets) {
+ totalSampleSize += dataSet.getNumRows();
+ }
+
+ int numColumns = dataSets.get(0).getNumColumns();
+ Matrix allData = new Matrix(totalSampleSize, numColumns);
+ int q = 0;
+ int r;
+
+ for (DataSet dataSet : dataSets) {
+ Matrix _data = dataSet.getDoubleData();
+ r = _data.getNumRows();
+
+ for (int i = 0; i < r; i++) {
+ for (int j = 0; j < numColumns; j++) {
+ allData.set(q + i, j, _data.get(i, j));
+ }
+ }
+
+ q += r;
+ }
+
+ return new BoxDataSet(new VerticalDoubleDataBox(allData.transpose().toArray()), dataSets.get(0).getVariables());
+ }
+
+ public static DataSet restrictToMeasured(DataSet fullDataSet) {
+ List measuredVars = new ArrayList<>();
+ List latentVars = new ArrayList<>();
+
+ for (Node node : fullDataSet.getVariables()) {
+ if (node.getNodeType() == NodeType.MEASURED) {
+ measuredVars.add(node);
+ } else {
+ latentVars.add(node);
+ }
+ }
+
+ return latentVars.isEmpty() ? fullDataSet : fullDataSet.subsetColumns(measuredVars);
+ }
+
+ /**
+ * @return a sample without replacement with the given sample size from the given dataset.
+ */
+ public static DataSet getResamplingDataset(DataSet data, int sampleSize) {
+ int actualSampleSize = data.getNumRows();
+ int _size = sampleSize;
+ if (actualSampleSize < _size) {
+ _size = actualSampleSize;
+ }
+
+ List availRows = new ArrayList<>();
+ for (int i = 0; i < actualSampleSize; i++) {
+ availRows.add(i);
+ }
+
+ RandomUtil.shuffle(availRows);
+
+ List addedRows = new ArrayList<>();
+ int[] rows = new int[_size];
+ for (int i = 0; i < _size; i++) {
+ int row = -1;
+ int index = -1;
+ while (row == -1 || addedRows.contains(row)) {
+ index = RandomUtil.getInstance().nextInt(availRows.size());
+ row = availRows.get(index);
+ }
+ rows[i] = row;
+ addedRows.add(row);
+ availRows.remove(index);
+ }
+
+ int[] cols = new int[data.getNumColumns()];
+ for (int i = 0; i < cols.length; i++) cols[i] = i;
+
+ return new BoxDataSet(new VerticalDoubleDataBox(data.getDoubleData().getSelection(rows, cols).transpose().toArray()), data.getVariables());
+ }
+
+ /**
+ * Get dataset sampled without replacement.
+ *
+ * @param data original dataset
+ * @param sampleSize number of data (row)
+ * @param randomGenerator random number generator
+ * @return dataset
+ */
+ public static DataSet getResamplingDataset(DataSet data, int sampleSize, RandomGenerator randomGenerator) {
+ int actualSampleSize = data.getNumRows();
+ int _size = sampleSize;
+ if (actualSampleSize < _size) {
+ _size = actualSampleSize;
+ }
+
+ List availRows = new ArrayList<>();
+ for (int i = 0; i < actualSampleSize; i++) {
+ availRows.add(i);
+ }
+
+ RandomUtil.shuffle(availRows);
+
+ List addedRows = new ArrayList<>();
+ int[] rows = new int[_size];
+ for (int i = 0; i < _size; i++) {
+ int row = -1;
+ int index = -1;
+ while (row == -1 || addedRows.contains(row)) {
+ index = randomGenerator.nextInt(availRows.size());
+ row = availRows.get(index);
+ }
+ rows[i] = row;
+ addedRows.add(row);
+ availRows.remove(index);
+ }
+
+ int[] cols = new int[data.getNumColumns()];
+ for (int i = 0; i < cols.length; i++) {
+ cols[i] = i;
+ }
+
+ return new BoxDataSet(new VerticalDoubleDataBox(data.getDoubleData().getSelection(rows, cols).transpose().toArray()), data.getVariables());
+ }
+
+ /**
+ * @return a sample with replacement with the given sample size from the given dataset.
+ */
+ public static DataSet getBootstrapSample(DataSet data, int sampleSize) {
+ int actualSampleSize = data.getNumRows();
+
+ int[] rows = new int[sampleSize];
+
+ for (int i = 0; i < rows.length; i++) {
+ rows[i] = RandomUtil.getInstance().nextInt(actualSampleSize);
+ }
+
+ int[] cols = new int[data.getNumColumns()];
+ for (int i = 0; i < cols.length; i++) cols[i] = i;
+
+ BoxDataSet boxDataSet = new BoxDataSet(new VerticalDoubleDataBox(data.getDoubleData().getSelection(rows, cols).transpose().toArray()),
+ data.getVariables());
+ boxDataSet.setKnowledge(data.getKnowledge());
+ return boxDataSet;
+ }
+
+ /**
+ * Get dataset sampled with replacement.
+ *
+ * @param data original dataset
+ * @param sampleSize number of data (row)
+ * @param randomGenerator random number generator
+ * @return dataset
+ */
+ public static DataSet getBootstrapSample(DataSet data, int sampleSize, RandomGenerator randomGenerator) {
+ int actualSampleSize = data.getNumRows();
+ int[] rows = new int[sampleSize];
+ for (int i = 0; i < rows.length; i++) {
+ rows[i] = randomGenerator.nextInt(actualSampleSize);
+ }
+
+ int[] cols = new int[data.getNumColumns()];
+ for (int i = 0; i < cols.length; i++) {
+ cols[i] = i;
+ }
+
+ BoxDataSet boxDataSet = new BoxDataSet(new VerticalDoubleDataBox(
+ data.getDoubleData().getSelection(rows, cols).transpose().toArray()),
+ data.getVariables());
+ boxDataSet.setKnowledge(data.getKnowledge());
+
+ return boxDataSet;
+ }
+
+ public static List split(DataSet data, double percentTest) {
+ if (percentTest <= 0 || percentTest >= 1) throw new IllegalArgumentException();
+
+ List rows = new ArrayList<>();
+ for (int i = 0; i < data.getNumRows(); i++) rows.add(i);
+
+ RandomUtil.shuffle(rows);
+
+ int split = (int) (rows.size() * percentTest);
+
+ List rows1 = new ArrayList<>();
+ List rows2 = new ArrayList<>();
+
+ for (int i = 0; i < split; i++) {
+ rows1.add(rows.get(i));
+ }
+
+ for (int i = split; i < rows.size(); i++) {
+ rows2.add(rows.get(i));
+ }
+
+ int[] _rows1 = new int[rows1.size()];
+ int[] _rows2 = new int[rows2.size()];
+
+ for (int i = 0; i < rows1.size(); i++) _rows1[i] = rows1.get(i);
+ for (int i = 0; i < rows2.size(); i++) _rows2[i] = rows2.get(i);
+
+ int[] cols = new int[data.getNumColumns()];
+ for (int i = 0; i < cols.length; i++) cols[i] = i;
+
+ BoxDataSet boxDataSet1 = new BoxDataSet(new VerticalDoubleDataBox(
+ data.getDoubleData().getSelection(_rows1, cols).transpose().toArray()),
+ data.getVariables());
+
+ BoxDataSet boxDataSet2 = new BoxDataSet(new VerticalDoubleDataBox(
+ data.getDoubleData().getSelection(_rows2, cols).transpose().toArray()),
+ data.getVariables());
+
+ List ret = new ArrayList<>();
+
+ ret.add(boxDataSet1);
+ ret.add(boxDataSet2);
+
+ return ret;
+ }
+
+ /**
+ * Subtracts the mean of each column from each datum that column.
+ */
+ public static DataSet center(DataSet data) {
+ DataSet _data = data.copy();
+
+ for (int j = 0; j < _data.getNumColumns(); j++) {
+ double sum = 0.0;
+ int n = 0;
+
+ for (int i = 0; i < _data.getNumRows(); i++) {
+ double v = _data.getDouble(i, j);
+
+ if (!Double.isNaN(v)) {
+ sum += v;
+ n++;
+ }
+ }
+
+ double avg = sum / n;
+
+ for (int i = 0; i < _data.getNumRows(); i++) {
+ _data.setDouble(i, j, _data.getDouble(i, j) - avg);
+ }
+ }
+
+ return _data;
+ }
+
+ public static DataSet shuffleColumns(DataSet dataModel) {
+ String name = dataModel.getName();
+ int numVariables = dataModel.getNumColumns();
+
+ List indicesList = new ArrayList<>();
+ for (int i = 0; i < numVariables; i++) indicesList.add(i);
+ RandomUtil.shuffle(indicesList);
+
+ int[] indices = new int[numVariables];
+
+ for (int i = 0; i < numVariables; i++) {
+ indices[i] = indicesList.get(i);
+ }
+
+ DataSet dataSet = dataModel.subsetColumns(indices);
+ dataSet.setName(name);
+ return dataSet;
+ }
+
+ public static List shuffleColumns2(List dataSets) {
+ List vars = new ArrayList<>();
+
+ List variables = dataSets.get(0).getVariables();
+ RandomUtil.shuffle(variables);
+
+ for (Node node : variables) {
+ Node _node = dataSets.get(0).getVariable(node.getName());
+
+ if (_node != null) {
+ vars.add(_node);
+ }
+ }
+
+ List ret = new ArrayList<>();
+
+ for (DataSet m : dataSets) {
+ DataSet data = m.subsetColumns(vars);
+ data.setName(m.getName() + ".reordered");
+ ret.add(data);
+ }
+
+ return ret;
+ }
+
+ public static ICovarianceMatrix covarianceNonparanormalDrton(DataSet dataSet) {
+ CovarianceMatrix covMatrix = new CovarianceMatrix(dataSet);
+ Matrix data = dataSet.getDoubleData();
+ int NTHREDS = Runtime.getRuntime().availableProcessors() * 10;
+ final int EPOCH_COUNT = 100000;
+
+ ExecutorService executor = Executors.newFixedThreadPool(NTHREDS);
+ int runnableCount = 0;
+
+ for (int _i = 0; _i < dataSet.getNumColumns(); _i++) {
+ for (int _j = _i; _j < dataSet.getNumColumns(); _j++) {
+ int i = _i;
+ int j = _j;
+
+ Runnable worker = () -> {
+ double tau = StatUtils.kendallsTau(data.getColumn(i).toArray(), data.getColumn(j).toArray());
+ covMatrix.setValue(i, j, tau);
+ covMatrix.setValue(j, i, tau);
+ };
+
+ executor.execute(worker);
+
+ if (runnableCount < EPOCH_COUNT) {
+ runnableCount++;
+// System.out.println(runnableCount);
+ } else {
+ executor.shutdown();
+ try {
+ // Wait until all threads are finish
+ boolean b = executor.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS);
+
+ if (b) {
+ System.out.println("Finished all threads");
+ }
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+
+ executor = Executors.newFixedThreadPool(NTHREDS);
+ runnableCount = 0;
+ }
+ }
+ }
+
+ executor.shutdown();
+
+ try {
+ // Wait until all threads are finish
+ boolean b = executor.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS);
+
+ if (b) {
+ System.out.println("Finished all threads");
+ }
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+
+ return covMatrix;
+ }
+
+ public static DataSet getNonparanormalTransformed(DataSet dataSet) {
+ try {
+ Matrix data = dataSet.getDoubleData();
+ Matrix X = data.like();
+ double n = dataSet.getNumRows();
+// delta = 1.0 / (4.0 * FastMath.pow(n, 0.25) * FastMath.sqrt(FastMath.PI * FastMath.log(n)));
+
+ NormalDistribution normalDistribution = new NormalDistribution();
+
+ double std = Double.NaN;
+
+ for (int j = 0; j < data.getNumColumns(); j++) {
+ double[] x1Orig = Arrays.copyOf(data.getColumn(j).toArray(), data.getNumRows());
+ double[] x1 = Arrays.copyOf(data.getColumn(j).toArray(), data.getNumRows());
+
+ double a2Orig = new AndersonDarlingTest(x1).getASquaredStar();
+
+ if (dataSet.getVariable(j) instanceof DiscreteVariable) {
+ X.assignColumn(j, new Vector(x1));
+ continue;
+ }
+
+ double std1 = StatUtils.sd(x1);
+ double mu1 = StatUtils.mean(x1);
+ double[] xTransformed = DataUtils.ranks(x1);
+
+ for (int i = 0; i < xTransformed.length; i++) {
+ xTransformed[i] /= n;
+ xTransformed[i] = normalDistribution.inverseCumulativeProbability(xTransformed[i]);
+ }
+
+ if (Double.isNaN(std)) {
+ std = StatUtils.sd(x1Orig);
+ }
+
+ for (int i = 0; i < xTransformed.length; i++) {
+ xTransformed[i] *= std1;
+ xTransformed[i] += mu1;
+ }
+
+ double a2Transformed = new AndersonDarlingTest(xTransformed).getASquaredStar();
+
+ double min = Double.POSITIVE_INFINITY;
+ double max = Double.NEGATIVE_INFINITY;
+
+ for (double v : xTransformed) {
+ if (v > max && !Double.isInfinite(v)) {
+ max = v;
+ }
+
+ if (v < min && !Double.isInfinite(v)) {
+ min = v;
+ }
+ }
+
+ for (int i = 0; i < xTransformed.length; i++) {
+ if (xTransformed[i] == Double.POSITIVE_INFINITY) {
+ xTransformed[i] = max;
+ }
+
+ if (xTransformed[i] < Double.NEGATIVE_INFINITY) {
+ xTransformed[i] = min;
+ }
+ }
+
+ System.out.println(dataSet.getVariable(j) + ": A^2* = " + a2Orig + " transformed A^2* = " + a2Transformed);
+
+// if (a2Transformed < a2Orig) {
+ X.assignColumn(j, new Vector(xTransformed));
+// } else {
+// X.assignColumn(j, new Vector(x1Orig));
+// }
+ }
+
+ return new BoxDataSet(new VerticalDoubleDataBox(X.transpose().toArray()), dataSet.getVariables());
+ } catch (OutOfRangeException e) {
+ e.printStackTrace();
+ return dataSet;
+ }
+ }
+
+ public static DataSet removeConstantColumns(DataSet dataSet) {
+ int columns = dataSet.getNumColumns();
+ int rows = dataSet.getNumRows();
+ if (rows == 0) {
+ return dataSet;
+ }
+
+ List keepCols = new ArrayList<>();
+
+ for (int j = 0; j < columns; j++) {
+ Object previous = dataSet.getObject(0, j);
+ boolean constant = true;
+ for (int row = 1; row < rows; row++) {
+ Object current = dataSet.getObject(row, j);
+ if (!previous.equals(current)) {
+ constant = false;
+ break;
+ }
+
+ if (previous instanceof Double && current instanceof Double) {
+ double _previouw = (Double) previous;
+ double _current = (Double) current;
+
+ if (Double.isNaN(_previouw) && Double.isNaN(_current)) {
+ constant = false;
+ break;
+ }
+ }
+ }
+
+ if (!constant) keepCols.add(j);
+ }
+
+ int[] newCols = new int[keepCols.size()];
+ for (int j = 0; j < keepCols.size(); j++) newCols[j] = keepCols.get(j);
+
+ return dataSet.subsetColumns(newCols);
+ }
+
+ public static List getConstantColumns(DataSet dataSet) {
+ List constantColumns = new ArrayList<>();
+ int rows = dataSet.getNumRows();
+
+ for (int j = 0; j < dataSet.getNumColumns(); j++) {
+ Object first = dataSet.getObject(0, j);
+ boolean constant = true;
+
+ for (int row = 1; row < rows; row++) {
+ Object current = dataSet.getObject(row, j);
+ if (!first.equals(current)) {
+ constant = false;
+ break;
+ }
+ }
+
+ if (constant) {
+ constantColumns.add(dataSet.getVariable(j));
+ }
+ }
+
+ return constantColumns;
+ }
+
+ public static DataSet removeRandomColumns(DataSet dataSet, double aDouble) {
+ int columns = dataSet.getNumColumns();
+ int rows = dataSet.getNumRows();
+ if (rows == 0) {
+ return dataSet;
+ }
+
+ List keepCols = new ArrayList<>();
+
+ for (int j = 0; j < columns; j++) {
+ if (RandomUtil.getInstance().nextDouble() > aDouble) {
+ keepCols.add(j);
+ }
+ }
+
+ int[] newCols = new int[keepCols.size()];
+ for (int j = 0; j < keepCols.size(); j++) newCols[j] = keepCols.get(j);
+
+ return dataSet.subsetColumns(newCols);
+ }
+
+ public static Matrix standardizeData(Matrix data) {
+ Matrix data2 = data.copy();
+
+ for (int j = 0; j < data2.getNumColumns(); j++) {
+ double sum = 0.0;
+
+ for (int i = 0; i < data2.getNumRows(); i++) {
+ sum += data2.get(i, j);
+ }
+
+ double mean = sum / data.getNumRows();
+
+ for (int i = 0; i < data.getNumRows(); i++) {
+ data2.set(i, j, data.get(i, j) - mean);
+ }
+
+ double norm = 0.0;
+
+ for (int i = 0; i < data.getNumRows(); i++) {
+ double v = data2.get(i, j);
+ norm += v * v;
+ }
+
+ norm = FastMath.sqrt(norm / (data.getNumRows() - 1));
+
+ for (int i = 0; i < data.getNumRows(); i++) {
+ data2.set(i, j, data2.get(i, j) / norm);
+ }
+ }
+
+ return data2;
+ }
+
+ public static double[] standardizeData(double[] data) {
+ double[] data2 = new double[data.length];
+
+ double sum = 0.0;
+
+ for (double d : data) {
+ sum += d;
+ }
+
+ double mean = sum / data.length;
+
+ for (int i = 0; i < data.length; i++) {
+ data2[i] = data[i] - mean;
+ }
+
+ double norm = 0.0;
+
+ for (double v : data2) {
+ norm += v * v;
+ }
+
+ norm = FastMath.sqrt(norm / (data2.length - 1));
+
+ for (int i = 0; i < data2.length; i++) {
+ data2[i] = data2[i] / norm;
+ }
+
+ return data2;
+ }
+
+ public static DoubleArrayList standardizeData(DoubleArrayList data) {
+ DoubleArrayList data2 = new DoubleArrayList(data.size());
+
+ double sum = 0.0;
+
+ for (int i = 0; i < data.size(); i++) {
+ sum += data.get(i);
+ }
+
+ double mean = sum / data.size();
+
+ for (int i = 0; i < data.size(); i++) {
+ data2.add(data.get(i) - mean);
+ }
+
+ double norm = 0.0;
+
+ for (int i = 0; i < data2.size(); i++) {
+ double v = data2.get(i);
+ norm += v * v;
+ }
+
+ norm = FastMath.sqrt(norm / (data2.size() - 1));
+
+ for (int i = 0; i < data2.size(); i++) {
+ data2.set(i, data2.get(i) / norm);
+ }
+
+ return data2;
+ }
+
+ public static double[] center(double[] d) {
+ double sum = 0.0;
+
+ for (double v : d) {
+ sum += v;
+ }
+
+ double mean = sum / d.length;
+ double[] d2 = new double[d.length];
+
+ for (int i = 0; i < d.length; i++) {
+ d2[i] = d[i] - mean;
+ }
+
+ return d2;
+ }
+
+ public static Matrix centerData(Matrix data) {
+ Matrix data2 = data.copy();
+
+ for (int j = 0; j < data2.getNumColumns(); j++) {
+ double sum = 0.0;
+
+ for (int i = 0; i < data2.getNumRows(); i++) {
+ sum += data2.get(i, j);
+ }
+
+ double mean = sum / data.getNumRows();
+
+ for (int i = 0; i < data.getNumRows(); i++) {
+ data2.set(i, j, data.get(i, j) - mean);
+ }
+ }
+
+ return data2;
+ }
+
+ public static Matrix concatenate(Matrix... dataSets) {
+ int totalSampleSize = 0;
+
+ for (Matrix dataSet : dataSets) {
+ totalSampleSize += dataSet.getNumRows();
+ }
+
+ int numColumns = dataSets[0].getNumColumns();
+ Matrix allData = new Matrix(totalSampleSize, numColumns);
+ int q = 0;
+ int r;
+
+ for (Matrix dataSet : dataSets) {
+ r = dataSet.getNumRows();
+
+ for (int i = 0; i < r; i++) {
+ for (int j = 0; j < numColumns; j++) {
+ allData.set(q + i, j, dataSet.get(i, j));
+ }
+ }
+
+ q += r;
+ }
+
+ return allData;
+ }
+
+ /**
+ * @return a sample with replacement with the given sample size from the given dataset.
+ */
+ public static Matrix getBootstrapSample(Matrix data, int sampleSize) {
+ int actualSampleSize = data.getNumRows();
+
+ int[] rows = new int[sampleSize];
+
+ for (int i = 0; i < rows.length; i++) {
+ rows[i] = RandomUtil.getInstance().nextInt(actualSampleSize);
+ }
+
+ int[] cols = new int[data.getNumColumns()];
+ for (int i = 0; i < cols.length; i++) cols[i] = i;
+
+ return data.getSelection(rows, cols);
+ }
+
+ public static void copyColumn(Node node, DataSet source, DataSet dest) {
+ int sourceColumn = source.getColumn(node);
+ int destColumn = dest.getColumn(node);
+ if (sourceColumn < 0) {
+ throw new NullPointerException("The given node was not in the source dataset");
+ }
+ if (destColumn < 0) {
+ throw new NullPointerException("The given node was not in the destination dataset");
+ }
+ int sourceRows = source.getNumRows();
+ int destRows = dest.getNumRows();
+ if (node instanceof ContinuousVariable) {
+ for (int i = 0; i < destRows && i < sourceRows; i++) {
+ dest.setDouble(i, destColumn, source.getDouble(i, sourceColumn));
+ }
+ } else if (node instanceof DiscreteVariable) {
+ for (int i = 0; i < destRows && i < sourceRows; i++) {
+ dest.setInt(i, destColumn, source.getInt(i, sourceColumn));
+ }
+ } else {
+ throw new IllegalArgumentException("The given variable most be discrete or continuous");
+ }
+ }
+
+ /**
+ * Adds missing data values to cases in accordance with probabilities specified in a double array which has as many
+ * elements as there are columns in the input dataset. Hence, if the first element of the array of probabilities is
+ * alpha, then the first column will contain a -99 (or other missing value code) in a given case with probability
+ * alpha. This method will be useful in generating datasets which can be used to test algorithm that handle missing
+ * data and/or latent variables. Author: Frank Wimberly
+ *
+ * @param inData The data to which random missing data is to be added.
+ * @param probs The probability of adding missing data to each column.
+ * @return The new data sets with missing data added.
+ */
+ public static DataSet addMissingData(
+ DataSet inData, double[] probs) {
+ DataSet outData;
+
+ outData = inData.copy();
+
+ if (probs.length != outData.getNumColumns()) {
+ throw new IllegalArgumentException(
+ "Wrong number of elements in prob array");
+ }
+
+ for (double prob : probs) {
+ if (prob < 0.0 || prob > 1.0) {
+ throw new IllegalArgumentException("Probability out of range");
+ }
+ }
+
+ for (int j = 0; j < outData.getNumColumns(); j++) {
+ Node node = outData.getVariable(j);
+
+ if (node instanceof ContinuousVariable) {
+ for (int i = 0; i < outData.getNumRows(); i++) {
+ if (RandomUtil.getInstance().nextDouble() < probs[j]) {
+ outData.setDouble(i, j, Double.NaN);
+ }
+ }
+ } else if (node instanceof DiscreteVariable) {
+ for (int i = 0; i < outData.getNumRows(); i++) {
+ if (RandomUtil.getInstance().nextDouble() < probs[j]) {
+ outData.setInt(i, j, -99);
+ }
+ }
+ }
+ }
+
+ return outData;
+ }
+
+ public static DataSet replaceMissingWithRandom(DataSet inData) {
+ DataSet outData;
+
+ try {
+ outData = new MarshalledObject<>(inData).get();
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+
+ for (int j = 0; j < outData.getNumColumns(); j++) {
+ Node variable = outData.getVariable(j);
+
+ if (variable instanceof DiscreteVariable) {
+ List values = new ArrayList<>();
+
+ for (int i = 0; i < outData.getNumRows(); i++) {
+ int value = outData.getInt(i, j);
+ if (value == -99) continue;
+ values.add(value);
+ }
+
+ Collections.sort(values);
+
+ for (int i = 0; i < outData.getNumRows(); i++) {
+ if (outData.getInt(i, j) == -99) {
+ int value = RandomUtil.getInstance().nextInt(values.size());
+ outData.setInt(i, j, values.get(value));
+ }
+ }
+ } else {
+ double min = Double.POSITIVE_INFINITY;
+ double max = Double.NEGATIVE_INFINITY;
+
+ for (int i = 0; i < outData.getNumRows(); i++) {
+ double value = outData.getDouble(i, j);
+ if (value < min) min = value;
+ if (value > max) max = value;
+ }
+
+ for (int i = 0; i < outData.getNumRows(); i++) {
+ double random = RandomUtil.getInstance().nextDouble();
+ outData.setDouble(i, j, min + random * (max - min));
+ }
+ }
+ }
+
+ return outData;
+ }
+}
+
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/DataUtils.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/DataUtils.java
index 27660ba7da..e82d7ad975 100755
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/DataUtils.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/DataUtils.java
@@ -21,25 +21,16 @@
package edu.cmu.tetrad.data;
-import cern.colt.list.DoubleArrayList;
import edu.cmu.tetrad.graph.GraphUtils;
import edu.cmu.tetrad.graph.Node;
-import edu.cmu.tetrad.graph.NodeType;
import edu.cmu.tetrad.util.Vector;
import edu.cmu.tetrad.util.*;
-import org.apache.commons.math3.distribution.NormalDistribution;
-import org.apache.commons.math3.exception.OutOfRangeException;
import org.apache.commons.math3.linear.BlockRealMatrix;
import org.apache.commons.math3.linear.RealMatrix;
-import org.apache.commons.math3.random.RandomGenerator;
import org.apache.commons.math3.util.FastMath;
-import java.rmi.MarshalledObject;
import java.util.*;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
import java.util.concurrent.ForkJoinPool;
-import java.util.concurrent.TimeUnit;
/**
* Some static utility methods for dealing with data sets.
@@ -48,32 +39,12 @@
*/
public final class DataUtils {
-
- public static void copyColumn(Node node, DataSet source, DataSet dest) {
- int sourceColumn = source.getColumn(node);
- int destColumn = dest.getColumn(node);
- if (sourceColumn < 0) {
- throw new NullPointerException("The given node was not in the source dataset");
- }
- if (destColumn < 0) {
- throw new NullPointerException("The given node was not in the destination dataset");
- }
- int sourceRows = source.getNumRows();
- int destRows = dest.getNumRows();
- if (node instanceof ContinuousVariable) {
- for (int i = 0; i < destRows && i < sourceRows; i++) {
- dest.setDouble(i, destColumn, source.getDouble(i, sourceColumn));
- }
- } else if (node instanceof DiscreteVariable) {
- for (int i = 0; i < destRows && i < sourceRows; i++) {
- dest.setInt(i, destColumn, source.getInt(i, sourceColumn));
- }
- } else {
- throw new IllegalArgumentException("The given variable most be discrete or continuous");
- }
+ /**
+ * Private constructor to prevent instantiation.
+ */
+ private DataUtils() {
}
-
/**
* States whether the given column of the given data set is binary.
*
@@ -113,104 +84,6 @@ public static String defaultCategory(int index) {
return Integer.toString(index);
}
- /**
- * Adds missing data values to cases in accordance with probabilities specified in a double array which has as many
- * elements as there are columns in the input dataset. Hence, if the first element of the array of probabilities is
- * alpha, then the first column will contain a -99 (or other missing value code) in a given case with probability
- * alpha. This method will be useful in generating datasets which can be used to test algorithm that handle missing
- * data and/or latent variables. Author: Frank Wimberly
- *
- * @param inData The data to which random missing data is to be added.
- * @param probs The probability of adding missing data to each column.
- * @return The new data sets with missing data added.
- */
- public static DataSet addMissingData(
- DataSet inData, double[] probs) {
- DataSet outData;
-
- outData = inData.copy();
-
- if (probs.length != outData.getNumColumns()) {
- throw new IllegalArgumentException(
- "Wrong number of elements in prob array");
- }
-
- for (double prob : probs) {
- if (prob < 0.0 || prob > 1.0) {
- throw new IllegalArgumentException("Probability out of range");
- }
- }
-
- for (int j = 0; j < outData.getNumColumns(); j++) {
- Node node = outData.getVariable(j);
-
- if (node instanceof ContinuousVariable) {
- for (int i = 0; i < outData.getNumRows(); i++) {
- if (RandomUtil.getInstance().nextDouble() < probs[j]) {
- outData.setDouble(i, j, Double.NaN);
- }
- }
- } else if (node instanceof DiscreteVariable) {
- for (int i = 0; i < outData.getNumRows(); i++) {
- if (RandomUtil.getInstance().nextDouble() < probs[j]) {
- outData.setInt(i, j, -99);
- }
- }
- }
- }
-
- return outData;
- }
-
- public static DataSet replaceMissingWithRandom(DataSet inData) {
- DataSet outData;
-
- try {
- outData = new MarshalledObject<>(inData).get();
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
-
- for (int j = 0; j < outData.getNumColumns(); j++) {
- Node variable = outData.getVariable(j);
-
- if (variable instanceof DiscreteVariable) {
- List values = new ArrayList<>();
-
- for (int i = 0; i < outData.getNumRows(); i++) {
- int value = outData.getInt(i, j);
- if (value == -99) continue;
- values.add(value);
- }
-
- Collections.sort(values);
-
- for (int i = 0; i < outData.getNumRows(); i++) {
- if (outData.getInt(i, j) == -99) {
- int value = RandomUtil.getInstance().nextInt(values.size());
- outData.setInt(i, j, values.get(value));
- }
- }
- } else {
- double min = Double.POSITIVE_INFINITY;
- double max = Double.NEGATIVE_INFINITY;
-
- for (int i = 0; i < outData.getNumRows(); i++) {
- double value = outData.getDouble(i, j);
- if (value < min) min = value;
- if (value > max) max = value;
- }
-
- for (int i = 0; i < outData.getNumRows(); i++) {
- double random = RandomUtil.getInstance().nextDouble();
- outData.setDouble(i, j, min + random * (max - min));
- }
- }
- }
-
- return outData;
- }
-
/**
* A discrete data set used to construct some other serializable instances.
*/
@@ -263,237 +136,6 @@ public static boolean containsMissingValue(DataSet data) {
return false;
}
- /**
- * Log or unlog data
- */
- public static DataSet logData(DataSet dataSet, double a, boolean isUnlog, int base) {
- Matrix data = dataSet.getDoubleData();
- Matrix X = data.like();
-
- for (int j = 0; j < data.getNumColumns(); j++) {
- double[] x1Orig = Arrays.copyOf(data.getColumn(j).toArray(), data.getNumRows());
- double[] x1 = Arrays.copyOf(data.getColumn(j).toArray(), data.getNumRows());
-
- if (dataSet.getVariable(j) instanceof DiscreteVariable) {
- X.assignColumn(j, new Vector(x1));
- continue;
- }
-
- for (int i = 0; i < x1.length; i++) {
- if (isUnlog) {
- if (base == 0) {
- x1[i] = FastMath.exp(x1Orig[i]) - a;
- } else {
- x1[i] = FastMath.pow(base, (x1Orig[i])) - a;
- }
- } else {
- double log = FastMath.log(a + x1Orig[i]);
- if (base == 0) {
- x1[i] = log;
- } else {
- x1[i] = log / FastMath.log(base);
- }
- }
- }
-
- X.assignColumn(j, new Vector(x1));
- }
-
- return new BoxDataSet(new VerticalDoubleDataBox(X.transpose().toArray()), dataSet.getVariables());
- }
-
-
- public static Matrix standardizeData(Matrix data) {
- Matrix data2 = data.copy();
-
- for (int j = 0; j < data2.getNumColumns(); j++) {
- double sum = 0.0;
-
- for (int i = 0; i < data2.getNumRows(); i++) {
- sum += data2.get(i, j);
- }
-
- double mean = sum / data.getNumRows();
-
- for (int i = 0; i < data.getNumRows(); i++) {
- data2.set(i, j, data.get(i, j) - mean);
- }
-
- double norm = 0.0;
-
- for (int i = 0; i < data.getNumRows(); i++) {
- double v = data2.get(i, j);
- norm += v * v;
- }
-
- norm = FastMath.sqrt(norm / (data.getNumRows() - 1));
-
- for (int i = 0; i < data.getNumRows(); i++) {
- data2.set(i, j, data2.get(i, j) / norm);
- }
- }
-
- return data2;
- }
-
- public static double[] standardizeData(double[] data) {
- double[] data2 = new double[data.length];
-
- double sum = 0.0;
-
- for (double d : data) {
- sum += d;
- }
-
- double mean = sum / data.length;
-
- for (int i = 0; i < data.length; i++) {
- data2[i] = data[i] - mean;
- }
-
- double norm = 0.0;
-
- for (double v : data2) {
- norm += v * v;
- }
-
- norm = FastMath.sqrt(norm / (data2.length - 1));
-
- for (int i = 0; i < data2.length; i++) {
- data2[i] = data2[i] / norm;
- }
-
- return data2;
- }
-
- public static DoubleArrayList standardizeData(DoubleArrayList data) {
- DoubleArrayList data2 = new DoubleArrayList(data.size());
-
- double sum = 0.0;
-
- for (int i = 0; i < data.size(); i++) {
- sum += data.get(i);
- }
-
- double mean = sum / data.size();
-
- for (int i = 0; i < data.size(); i++) {
- data2.add(data.get(i) - mean);
- }
-
- double norm = 0.0;
-
- for (int i = 0; i < data2.size(); i++) {
- double v = data2.get(i);
- norm += v * v;
- }
-
- norm = FastMath.sqrt(norm / (data2.size() - 1));
-
- for (int i = 0; i < data2.size(); i++) {
- data2.set(i, data2.get(i) / norm);
- }
-
- return data2;
- }
-
- public static List standardizeData(List dataSets) {
- List outList = new ArrayList<>();
-
- for (DataSet dataSet : dataSets) {
- if (!(dataSet.isContinuous())) {
- throw new IllegalArgumentException("Not a continuous data set: " + dataSet.getName());
- }
-
- Matrix data2 = DataUtils.standardizeData(dataSet.getDoubleData());
-
- DataSet dataSet2 = new BoxDataSet(new VerticalDoubleDataBox(data2.transpose().toArray()), dataSet.getVariables());
- outList.add(dataSet2);
- }
-
- return outList;
- }
-
- public static DataSet standardizeData(DataSet dataSet) {
- List dataSets = Collections.singletonList(dataSet);
- List outList = DataUtils.standardizeData(dataSets);
- return outList.get(0);
- }
-
- public static double[] center(double[] d) {
- double sum = 0.0;
-
- for (double v : d) {
- sum += v;
- }
-
- double mean = sum / d.length;
- double[] d2 = new double[d.length];
-
- for (int i = 0; i < d.length; i++) {
- d2[i] = d[i] - mean;
- }
-
- return d2;
- }
-
- public static Matrix centerData(Matrix data) {
- Matrix data2 = data.copy();
-
- for (int j = 0; j < data2.getNumColumns(); j++) {
- double sum = 0.0;
-
- for (int i = 0; i < data2.getNumRows(); i++) {
- sum += data2.get(i, j);
- }
-
- double mean = sum / data.getNumRows();
-
- for (int i = 0; i < data.getNumRows(); i++) {
- data2.set(i, j, data.get(i, j) - mean);
- }
- }
-
- return data2;
- }
-
- public static List center(List dataList) {
- List dataSets = new ArrayList<>(dataList);
- List outList = new ArrayList<>();
-
- for (DataSet model : dataSets) {
- if (model == null) {
- throw new NullPointerException("Missing dataset.");
- }
-
- if (!(model.isContinuous())) {
- throw new IllegalArgumentException("Not a continuous data set: " + model.getName());
- }
-
- Matrix data2 = DataUtils.centerData(model.getDoubleData());
- List list = model.getVariables();
- List list2 = new ArrayList<>(list);
-
- DataSet dataSet2 = new BoxDataSet(new VerticalDoubleDataBox(data2.transpose().toArray()), list2);
- outList.add(dataSet2);
- }
-
- return outList;
- }
-
-
- public static DataSet discretize(DataSet dataSet, int numCategories, boolean variablesCopied) {
- Discretizer discretizer = new Discretizer(dataSet);
- discretizer.setVariablesCopied(variablesCopied);
-
- for (Node node : dataSet.getVariables()) {
-// if (dataSet.getVariable(node.getNode()) instanceof ContinuousVariable) {
- discretizer.equalIntervals(node, numCategories);
-// }
- }
-
- return discretizer.discretize();
- }
public static List createContinuousVariables(String[] varNames) {
List variables = new LinkedList<>();
@@ -640,173 +282,6 @@ public static Matrix subMatrix(ICovarianceMatrix m, Map indexMap,
return m.getSelection(indices, indices);
}
- public static DataSet convertNumericalDiscreteToContinuous(
- DataSet dataSet) throws NumberFormatException {
- List variables = new ArrayList<>();
-
- for (Node variable : dataSet.getVariables()) {
- if (variable instanceof ContinuousVariable) {
- variables.add(variable);
- } else {
- variables.add(new ContinuousVariable(variable.getName()));
- }
- }
-
- DataSet continuousData = new BoxDataSet(new VerticalDoubleDataBox(dataSet.getNumRows(), variables.size()), variables);
-
- for (int j = 0; j < dataSet.getNumColumns(); j++) {
- Node variable = dataSet.getVariable(j);
-
- if (variable instanceof ContinuousVariable) {
- for (int i = 0; i < dataSet.getNumRows(); i++) {
- continuousData.setDouble(i, j, dataSet.getDouble(i, j));
- }
- } else {
- DiscreteVariable discreteVariable = (DiscreteVariable) variable;
-
- boolean allNumerical = true;
-
- for (String cat : discreteVariable.getCategories()) {
- try {
- Double.parseDouble(cat);
- } catch (NumberFormatException e) {
- allNumerical = false;
- break;
- }
- }
-
-
- for (int i = 0; i < dataSet.getNumRows(); i++) {
- int index = dataSet.getInt(i, j);
- String catName = discreteVariable.getCategory(index);
- double value;
-
- if (catName.equals("*")) {
- value = Double.NaN;
- } else {
- if (allNumerical) {
- value = Double.parseDouble(catName);
- } else {
- value = index;
- }
- }
-
- continuousData.setDouble(i, j, value);
- }
- }
- }
-
- return continuousData;
- }
-
- public static DataSet concatenate(DataSet dataSet1, DataSet dataSet2) {
- List vars1 = dataSet1.getVariables();
- List vars2 = dataSet2.getVariables();
- Map varMap2 = new HashMap<>();
- for (int i = 0; i < vars2.size(); i++) {
- varMap2.put(vars2.get(i).getName(), i);
- }
- int rows1 = dataSet1.getNumRows();
- int rows2 = dataSet2.getNumRows();
- int cols1 = dataSet1.getNumColumns();
-
- Matrix concatMatrix = new Matrix(rows1 + rows2, cols1);
- Matrix matrix1 = dataSet1.getDoubleData();
- Matrix matrix2 = dataSet2.getDoubleData();
-
- for (int i = 0; i < vars1.size(); i++) {
- int var2 = varMap2.get(vars1.get(i).getName());
- for (int j = 0; j < rows1; j++) {
- concatMatrix.set(j, i, matrix1.get(j, i));
- }
- for (int j = 0; j < rows2; j++) {
- concatMatrix.set(j + rows1, i, matrix2.get(j, var2));
- }
- }
-
- return new BoxDataSet(new VerticalDoubleDataBox(concatMatrix.transpose().toArray()), vars1);
- }
-
-
- public static DataSet concatenate(DataSet... dataSets) {
- List _dataSets = new ArrayList<>();
-
- Collections.addAll(_dataSets, dataSets);
-
- return DataUtils.concatenate(_dataSets);
- }
-
- public static Matrix concatenate(Matrix... dataSets) {
- int totalSampleSize = 0;
-
- for (Matrix dataSet : dataSets) {
- totalSampleSize += dataSet.getNumRows();
- }
-
- int numColumns = dataSets[0].getNumColumns();
- Matrix allData = new Matrix(totalSampleSize, numColumns);
- int q = 0;
- int r;
-
- for (Matrix dataSet : dataSets) {
- r = dataSet.getNumRows();
-
- for (int i = 0; i < r; i++) {
- for (int j = 0; j < numColumns; j++) {
- allData.set(q + i, j, dataSet.get(i, j));
- }
- }
-
- q += r;
- }
-
- return allData;
- }
-
- // Trying to optimize some.
- public static DataSet concatenate(List dataSets) {
- int totalSampleSize = 0;
-
- for (DataSet dataSet : dataSets) {
- totalSampleSize += dataSet.getNumRows();
- }
-
- int numColumns = dataSets.get(0).getNumColumns();
- Matrix allData = new Matrix(totalSampleSize, numColumns);
- int q = 0;
- int r;
-
- for (DataSet dataSet : dataSets) {
- Matrix _data = dataSet.getDoubleData();
- r = _data.getNumRows();
-
- for (int i = 0; i < r; i++) {
- for (int j = 0; j < numColumns; j++) {
- allData.set(q + i, j, _data.get(i, j));
- }
- }
-
- q += r;
- }
-
- return new BoxDataSet(new VerticalDoubleDataBox(allData.transpose().toArray()), dataSets.get(0).getVariables());
- }
-
- public static DataSet restrictToMeasured(DataSet fullDataSet) {
- List measuredVars = new ArrayList<>();
- List latentVars = new ArrayList<>();
-
- for (Node node : fullDataSet.getVariables()) {
- if (node.getNodeType() == NodeType.MEASURED) {
- measuredVars.add(node);
- } else {
- latentVars.add(node);
- }
- }
-
- return latentVars.isEmpty() ? fullDataSet : fullDataSet.subsetColumns(measuredVars);
- }
-
public static Vector means(Matrix data) {
Vector means = new Vector(data.getNumColumns());
@@ -1002,463 +477,6 @@ public static DataSet choleskySimulation(CovarianceMatrix cov) {
return dataSet;
}
- /**
- * @return a sample with replacement with the given sample size from the given dataset.
- */
- public static Matrix getBootstrapSample(Matrix data, int sampleSize) {
- int actualSampleSize = data.getNumRows();
-
- int[] rows = new int[sampleSize];
-
- for (int i = 0; i < rows.length; i++) {
- rows[i] = RandomUtil.getInstance().nextInt(actualSampleSize);
- }
-
- int[] cols = new int[data.getNumColumns()];
- for (int i = 0; i < cols.length; i++) cols[i] = i;
-
- return data.getSelection(rows, cols);
- }
-
- /**
- * @return a sample without replacement with the given sample size from the given dataset.
- */
- public static DataSet getResamplingDataset(DataSet data, int sampleSize) {
- int actualSampleSize = data.getNumRows();
- int _size = sampleSize;
- if (actualSampleSize < _size) {
- _size = actualSampleSize;
- }
-
- List availRows = new ArrayList<>();
- for (int i = 0; i < actualSampleSize; i++) {
- availRows.add(i);
- }
-
- RandomUtil.shuffle(availRows);
-
- List