// Sorts labels from the mapping. We may get rid of this later perhaps. String[] revisedLabels(HashMap map) { // Sort labels String[] labels = new String[map.size()]; labels = (String[]) (map.keySet().toArray(labels)); Arrays.sort(labels); return labels; }
public XYSeries getXYSeries(String rowname, long factor) { XYSeries mydataset = new XYSeries(rowname); for (Integer key : ysum.keySet()) { Double value = ysum.get(key) / (double) count.get(key); Double point = (double) xsum.get(key) / (double) count.get(key); mydataset.add(point / factor, value); } return mydataset; }
public YIntervalSeries getYIntervalSeries(String rowname, long factor) { YIntervalSeries mydataset = new YIntervalSeries(rowname); double sdcount = 0; double total = 0; Vector<Double> totalvalues = new Vector<Double>(); double avgtotal = 0; double minus = 0; double plus = 0; double zero = 0; for (Integer key : ysum.keySet()) { Double value = ysum.get(key) / (double) count.get(key); Double point = (double) xsum.get(key) / (double) count.get(key); Vector<Double> listofvalues = values.get(key); double sumofdiff = 0.0; for (Double onevalue : listofvalues) { sumofdiff += Math.pow(onevalue - value, 2); sdcount++; total += Math.pow(onevalue, 2); avgtotal += onevalue; totalvalues.add(onevalue); if (onevalue == 1) { plus++; } ; if (onevalue == -1) { minus++; } ; if (onevalue == 0) { zero++; } ; } double sd = Math.sqrt(sumofdiff / count.get(key)); // mydataset.add(point/factor, value,value+sd,value-sd); // mydataset.add(point/factor, value,value,value); mydataset.add( point / factor, value, value + 1.96 * (sd / Math.sqrt(count.get(key))), value - 1.96 * (sd / Math.sqrt(count.get(key)))); } double sdtotal = 0; double avgsd = total / sdcount; double test = 0; for (Double onevalue : totalvalues) { sdtotal += Math.pow(Math.pow(onevalue, 2) - (total / sdcount), 2); test += onevalue; } // System.out.println(rowname+" mean square: "+avgsd+" // +/-95%:"+1.96*Math.sqrt(sdtotal/sdcount)/Math.sqrt(sdcount)); // System.out.println("total -1:"+minus+" total +1:"+plus+" zero: "+zero // +" total:"+sdcount); return mydataset; }