# /* vim: set filetype=awk : */ -*- awk -*- BEGIN { FS = OFS = ","; Trust = 95; } { Thing[$1] = 1; Thing[$2] = 1; N[$1,$2]++; Sum[$1,$2] += $3; SumSq[$1,$2] += $3*$3; } END { for(I in Thing) for(J in Thing) if (I > J) winLossTie(I,J,N[I,J],Sum[I,J],SumSq[I,J]); print "#what,win-loss,win,loss,tie" for(I in Thing) report(I) } function winLossTie(i,j,n,sum,sumSq, comp) { comp= compare(mean(n,sum), sd(n,sum,sumSq), n, (Degrees ? Degrees : n - 1), ((1 - (Trust/100)) "") + 0); #bizare conversion error. just on macs? if (comp == 0) { Tie[i]++; Tie[j]++; } if (comp > 0) { Win[i]++; Loss[j]++; } if (comp < 0) { Loss[i]++; Win[j]++; } } function report(i, a,w,l,t) { w = Win[i]; l = Loss[i]; t = Tie[i]; a = w+l+t; print i,100*(w - l)/a, 100*w/a, 100*l/a,100*t/a | "sort -t, -r -n +1" } function mean(n,sum) { return sum/n } function sd( n,sum,sumSq) { return sqrt((sumSq-((sum*sum)/n))/(n-1)) } function compare(mean,sd,n,k,alpha) { if ( same(mean,sd,n,k,alpha) ) return 0; if ( mean < 0 ) return -1; if ( mean > 0 ) return 1; } function same(mean,sd,n,k,alpha, t) { if (!sd) return (mean==0); ## same if no deviation and zero mean t = tval(mean,sd,n); t = t<0 ? -1*t : t; return t < t2table(k,alpha); } function tval(mean,sd,n) { return mean/(sd/sqrt(n)) } function t2table(f,l, r) { if ( ( l != 0.05 && l != 0.01 ) || f < 1 ) { print "ttest internal panic! can't handle l=["l"] and f=["f"]"; exit -1}; if (f < 31) { return T2[f,l]}; if (f < 101) { f=int(f/5)*5; return T2[f,l]}; if (f < 350) { return T2[200,l] }; if (f < 750) { return T2[500,l] } r=T2[1000,l]; if (!r) print "ERROR in t-test; unknown alpha="alpha" degrees="k " values"; return r; } BEGIN { ## magic thresholds for 95 and 99% confidence tests. T2[1,0.05] = 12.706; T2[1,0.01] = 63.6570; T2[2,0.05] = 4.3030; T2[2,0.01] = 9.9250; T2[3,0.05] = 3.1820; T2[3,0.01] = 5.8410; T2[4,0.05] = 2.7760; T2[4,0.01] = 4.6040; T2[5,0.05] = 2.5710; T2[5,0.01] = 4.0320; T2[6,0.05] = 2.4470; T2[6,0.01] = 3.7070; T2[7,0.05] = 2.3650; T2[7,0.01] = 3.4990; T2[8,0.05] = 2.3060; T2[8,0.01] = 3.3550; T2[9,0.05] = 2.2620; T2[9,0.01] = 3.2500; T2[10,0.05] = 2.2280; T2[10,0.01] = 3.1690; T2[11,0.05] = 2.2010; T2[11,0.01] = 3.1060; T2[12,0.05] = 2.1790; T2[12,0.01] = 3.0550; T2[13,0.05] = 2.1600; T2[13,0.01] = 3.0120; T2[14,0.05] = 2.1450; T2[14,0.01] = 2.9770; T2[15,0.05] = 2.1310; T2[15,0.01] = 2.9470; T2[16,0.05] = 2.1200; T2[16,0.01] = 2.9210; T2[17,0.05] = 2.1100; T2[17,0.01] = 2.8980; T2[18,0.05] = 2.1010; T2[18,0.01] = 2.8780; T2[19,0.05] = 2.0930; T2[19,0.01] = 2.8610; T2[20,0.05] = 2.0860; T2[20,0.01] = 2.8450; T2[21,0.05] = 2.0800; T2[21,0.01] = 2.8310; T2[22,0.05] = 2.0740; T2[22,0.01] = 2.8190; T2[23,0.05] = 2.0690; T2[23,0.01] = 2.8070; T2[24,0.05] = 2.0640; T2[24,0.01] = 2.7970; T2[25,0.05] = 2.0600; T2[25,0.01] = 2.7870; T2[26,0.05] = 2.0560; T2[26,0.01] = 2.7790; T2[27,0.05] = 2.0520; T2[27,0.01] = 2.7710; T2[28,0.05] = 2.0480; T2[28,0.01] = 2.7630; T2[29,0.05] = 2.0450; T2[29,0.01] = 2.7560; T2[30,0.05] = 2.0420; T2[30,0.01] = 2.7500; T2[35,0.05] = 2.03; T2[35,0.01] = 2.72; T2[40,0.05] = 2.02; T2[40,0.01] = 2.7; T2[45,0.05] = 2.01; T2[45,0.01] = 2.69; T2[50,0.05] = 2.01; T2[50,0.01] = 2.68; T2[55,0.05] = 2; T2[55,0.01] = 2.67; T2[60,0.05] = 2; T2[60,0.01] = 2.66; T2[65,0.05] = 2; T2[65,0.01] = 2.65; T2[70,0.05] = 1.99; T2[70,0.01] = 2.65; T2[75,0.05] = 1.99; T2[75,0.01] = 2.64; T2[80,0.05] = 1.99; T2[80,0.01] = 2.64; T2[85,0.05] = 1.99; T2[85,0.01] = 2.63; T2[90,0.05] = 1.99; T2[90,0.01] = 2.63; T2[95,0.05] = 1.99; T2[95,0.01] = 2.63; T2[100,0.05] = 1.98; T2[100,0.01] = 2.63; T2[200,0.05] = 1.97; T2[200,0.01] = 2.6; T2[500,0.05] = 1.96; T2[500,0.01] = 2.59; T2[1000,0.05] = 1.96; T2[1000,0.01] = 2.58; T2["inf",0.05] = 1.96; T2["inf",0.01] = 2.58; }