/** * @param args * @throws IOException */ public void results(String[] f) throws IOException { String[] indicators = {"EPSILON", "IGD", "SPREAD", "HV"}; String[] operators = {"BLX", "SBX" // ,"DEX" }; int runs = 15; double aux = 0; String str = ""; BufferedReader br = null; Vector<PrintWriter> pw = new Vector<PrintWriter>(); DescriptiveStatistics d = new DescriptiveStatistics(); for (int i = 0; i < operators.length; i++) { for (int j = 0; j < indicators.length; j++) { pw.add( new PrintWriter( "C:\\Users\\9dgonzalezg\\Desktop\\workspace\\GA\\GA" + "\\resultsMyNSGAIIExperiment\\data\\" + new String(f[i]) + "_" + indicators[j] + ".res")); for (int k = 0; k < runs; k++) { br = new BufferedReader( new FileReader( "C:\\Users\\9dgonzalezg" + "\\Desktop\\workspace\\GA\\GA\\resultsMyNSGAIIExperiment\\" + "data\\" + f[i] + "\\" + new Integer(k).toString() + "\\" + indicators[j])); str = br.readLine(); while (str != null) { aux = Double.parseDouble(str); d.addValue(aux); str = br.readLine(); } br.close(); pw.get(j).println(d.getMean()); d.clear(); } pw.get(j).close(); } pw.clear(); } }
public Vector<double[]> getMeanSd(svm_node[][] node) { // TODO Auto-generated method stub DescriptiveStatistics statistics = new DescriptiveStatistics(); int nAttr = node[0].length; int nSample = node.length; double[] meanValues = new double[nAttr]; double[] sdValues = new double[nAttr]; for (int i = 0; i < nAttr; i++) { statistics.clear(); for (int j = 0; j < nSample; j++) { statistics.addValue(node[j][i].value); } // 获取中值及标准差 meanValues[i] = statistics.getMean(); sdValues[i] = statistics.getStandardDeviation(); } Vector<double[]> meanSd = new Vector<double[]>(); meanSd.add(meanValues); meanSd.add(sdValues); return meanSd; }