| 890 | } |
| 891 | |
| 892 | public void summarize() { |
| 893 | if (rt==null || "Max".equals(rt.getLabel(rt.size()-1))) |
| 894 | return; |
| 895 | int n = rt.size(); |
| 896 | if (n<2) |
| 897 | return; |
| 898 | String[] headings = rt.getHeadings(); |
| 899 | int columns = headings.length; |
| 900 | if (columns==0) |
| 901 | return; |
| 902 | int first = "Label".equals(headings[0])?1:0; |
| 903 | double[] min = new double[columns]; |
| 904 | double[] max = new double[columns]; |
| 905 | double[] sum = new double[columns]; |
| 906 | double[] sum2 = new double[columns]; |
| 907 | for (int i=0; i<columns; i++) { |
| 908 | min[i] = Double.MAX_VALUE; |
| 909 | max[i] = -Double.MAX_VALUE; |
| 910 | } |
| 911 | for (int row=0; row<n; row++) { |
| 912 | for (int col=first; col<columns; col++) { |
| 913 | double v = rt.getValue(headings[col], row); |
| 914 | if (v<min[col]) min[col]=v; |
| 915 | if (v>max[col]) max[col]=v; |
| 916 | sum[col]+=v; |
| 917 | sum2[col]+=v*v; |
| 918 | } |
| 919 | } |
| 920 | rt.incrementCounter(); rt.setLabel("Mean", n+0); |
| 921 | rt.incrementCounter(); rt.setLabel("SD", n+1); |
| 922 | rt.incrementCounter(); rt.setLabel("Min", n+2); |
| 923 | rt.incrementCounter(); rt.setLabel("Max", n+3); |
| 924 | for (int col=first; col<columns; col++) { |
| 925 | rt.setValue(headings[col], n+0, sum[col]/n); |
| 926 | rt.setValue(headings[col], n+1, Math.sqrt((sum2[col]-sum[col]*sum[col]/n)/(n-1))); |
| 927 | rt.setValue(headings[col], n+2, min[col]); |
| 928 | rt.setValue(headings[col], n+3, max[col]); |
| 929 | } |
| 930 | rt.show(rt.getTitle()); |
| 931 | } |
| 932 | |
| 933 | /** Returns the current measurement count. */ |
| 934 | public static int getCounter() { |