public static void writeStatistics(TDoubleObjectHashMap<DescriptiveStatistics> statsMap,String keyLabel,String file) throws IOException {
  double[] keys=statsMap.keys();
  Arrays.sort(keys);
  BufferedWriter writer=new BufferedWriter(new FileWriter(file));
  writer.write(keyLabel);
  writer.write(TAB);
  writer.write("mean");
  writer.write(TAB);
  writer.write("median");
  writer.write(TAB);
  writer.write("min");
  writer.write(TAB);
  writer.write("max");
  writer.write(TAB);
  writer.write("n");
  writer.newLine();
  for (  double key : keys) {
    DescriptiveStatistics stats=statsMap.get(key);
    writer.write(String.valueOf(key));
    writer.write(TAB);
    writer.write(String.valueOf(stats.getMean()));
    writer.write(TAB);
    writer.write(String.valueOf(stats.getPercentile(50)));
    writer.write(TAB);
    writer.write(String.valueOf(stats.getMin()));
    writer.write(TAB);
    writer.write(String.valueOf(stats.getMax()));
    writer.write(TAB);
    writer.write(String.valueOf(stats.getN()));
    writer.newLine();
  }
  writer.close();
}

public static void writeStatistics ( TDoubleObjectHashMap < DescriptiveStatistics > statsMap , String keyLabel , String file ) throws IOException { double [ ] keys = statsMap . keys ( ) ; Arrays . sort ( keys ) ; BufferedWriter writer = new BufferedWriter ( new FileWriter ( file ) ) ; writer . write ( keyLabel ) ; writer . write ( TAB ) ; writer . write ( "mean" ) ; writer . write ( TAB ) ; writer . write ( "median" ) ; writer . write ( TAB ) ; writer . write ( "min" ) ; writer . write ( TAB ) ; writer . write ( "max" ) ; writer . write ( TAB ) ; writer . write ( "n" ) ; writer . newLine ( ) ; for ( double key : keys ) { DescriptiveStatistics stats = statsMap . get ( key ) ; writer . write ( String . valueOf ( key ) ) ; writer . write ( TAB ) ; writer . write ( String . valueOf ( stats . getMean ( ) ) ) ; writer . write ( TAB ) ; writer . write ( String . valueOf ( stats . getPercentile ( 50 ) ) ) ; writer . write ( TAB ) ; writer . write ( String . valueOf ( stats . getMin ( ) ) ) ; writer . write ( TAB ) ; writer . write ( String . valueOf ( stats . getMax ( ) ) ) ; writer . write ( TAB ) ; writer . write ( String . valueOf ( stats . getN ( ) ) ) ; writer . newLine ( ) ; } writer . close ( ) ; }
writes a table with columns map - key and statistical indicators mean , median , min , max and number of samples . rows are sorted according to the natural order of the map keys .
