#incoming data looks like #FILENAME,I,LEARNER,SEARCH,HORIZON,RANKER,EVAL,ESTIMATE,ACTUAL,MRE,COST_DRIVERS BEGIN { FS = ","; # Initialize the field separator. OFS = ","; # Initialize the output field separator. Pred = 30; # Initialize the range for Pred. } { Mre = $10; SumMre += Mre; SumMreSq += Mre^2; if (Mre < Pred) PredN++ Subset=$11 for(I=1; I<=15; I++) { target="-"I"-"; if (index(Subset, target)!=0) { #Count[I]++; CostDriverSum++; } } } END { Mmre = SumMre/NR; Pred30 = 100*(PredN/NR); SdMre = sd(SumMreSq,SumMre,NR); print Mmre, Pred30, SdMre, CostDriverSum/NR; } function sd(sumSq,sumX,n) { return sqrt((sumSq-((sumX*sumX) / n)) / (n-1)) }