use of edu.pitt.dbmi.data.reader.tabular.ContinuousTabularDataFileReader in project tetrad by cmu-phil.
the class GdistanceRandomApply method main.
public static void main(String... args) {
// thresholds are the barriers between histogram buckets.
double[] thresholds;
thresholds = new double[5];
thresholds[0] = 0;
thresholds[1] = 2;
thresholds[2] = 4;
thresholds[3] = 6;
thresholds[4] = 8;
// load the location map
String workingDirectory = System.getProperty("user.dir");
System.out.println(workingDirectory);
Path mapPath = Paths.get("erich_coordinates.txt");
System.out.println(mapPath);
TabularDataReader dataReaderMap = new ContinuousTabularDataFileReader(mapPath.toFile(), Delimiter.COMMA);
try {
DataSet locationMap = (DataSet) DataConvertUtils.toDataModel(dataReaderMap.readInData());
System.out.println("locationMap loaded");
GdistanceRandom simRandGdistances = new GdistanceRandom(locationMap);
System.out.println("GdistanceRandom constructed");
simRandGdistances.setNumEdges1(300);
simRandGdistances.setNumEdges2(300);
simRandGdistances.setVerbose(false);
System.out.println("Edge parameters set, starting simulations");
List<List<Double>> GdistanceLists = simRandGdistances.randomSimulation(2);
System.out.println("Simulations done, calculating histograms");
for (List<Double> gdist : GdistanceLists) {
double[] histogram = GdistanceUtils.histogram(gdist, thresholds);
// making the string to print out histogram values
String histString = " ";
for (int i = 0; i < Array.getLength(histogram); i++) {
histString = histString + " " + histogram[i];
}
System.out.println(histString);
}
} catch (Exception IOException) {
IOException.printStackTrace();
}
}
use of edu.pitt.dbmi.data.reader.tabular.ContinuousTabularDataFileReader in project tetrad by cmu-phil.
the class TestDM method readAndSearchData.
// Reads in data and runs search. Note: Assumes variable names are of the form X0, X1, etc.
// Both input and output integer arrays are the indexes of their respective variables.
public DMSearch readAndSearchData(String fileLocation, int[] inputs, int[] outputs, boolean useGES, int[] trueInputs) {
File file = new File(fileLocation);
DataSet data = null;
try {
TabularDataReader dataReader = new ContinuousTabularDataFileReader(file, Delimiter.SPACE);
data = (DataSet) DataConvertUtils.toDataModel(dataReader.readInData());
} catch (IOException e) {
print("Failed to read in data.");
e.printStackTrace();
}
print("Read Data");
DMSearch search = new DMSearch();
search.setInputs(inputs);
search.setOutputs(outputs);
if (useGES == false) {
search.setAlphaPC(.05);
search.setUseFges(useGES);
search.setData(data);
search.setTrueInputs(trueInputs);
search.search();
} else {
search.setData(data);
search.setTrueInputs(trueInputs);
search.search();
// search.search(data, trueInputs);
}
return (search);
}
Aggregations