public static QualityStats average(QualityStats[] stats) {QualityStats avg = new QualityStats(0,0);if (stats.length==0) {return avg;}int m = 0; for (int i=0; i<stats.length; i++) {avg.searchTime += stats[i].searchTime;avg.docNamesExtractTime += stats[i].docNamesExtractTime;if (stats[i].maxGoodPoints>0) {m++;avg.numGoodPoints += stats[i].numGoodPoints;avg.numPoints += stats[i].numPoints;avg.pReleventSum += stats[i].getAvp();avg.recall += stats[i].recall;avg.mrr += stats[i].getMRR();avg.maxGoodPoints += stats[i].maxGoodPoints;for (int j=1; j<avg.pAt.length; j++) {avg.pAt[j] += stats[i].getPrecisionAt(j);}}}assert m>0 : "Fishy: no \"good\" queries!";avg.searchTime /= stats.length;avg.docNamesExtractTime /= stats.length;avg.numGoodPoints /= m;avg.numPoints /= m;avg.recall /= m;avg.mrr /= m;avg.maxGoodPoints /= m;for (int j=1; j<avg.pAt.length; j++) {avg.pAt[j] /= m;}avg.pReleventSum /= m;                 avg.pReleventSum *= avg.maxGoodPoints; return avg;}

public static QualityStats Average(QualityStats[] stats){QualityStats avg = new QualityStats(0, 0);if (stats.Length == 0){return avg;}int m = 0; for (int i = 0; i < stats.Length; i++){avg.searchTime += stats[i].searchTime;avg.docNamesExtractTime += stats[i].docNamesExtractTime;if (stats[i].maxGoodPoints > 0){m++;avg.numGoodPoints += stats[i].numGoodPoints;avg.numPoints += stats[i].numPoints;avg.pReleventSum += stats[i].GetAvp();avg.recall += stats[i].recall;avg.mrr += stats[i].MRR;avg.maxGoodPoints += stats[i].maxGoodPoints;for (int j = 1; j < avg.pAt.Length; j++){avg.pAt[j] += stats[i].GetPrecisionAt(j);}}}Debug.Assert(m> 0, "Fishy: no \"good\" queries!");avg.searchTime /= stats.Length;avg.docNamesExtractTime /= stats.Length;avg.numGoodPoints /= m;avg.numPoints /= m;avg.recall /= m;avg.mrr /= m;avg.maxGoodPoints /= m;for (int j = 1; j < avg.pAt.Length; j++){avg.pAt[j] /= m;}avg.pReleventSum /= m;                 avg.pReleventSum *= avg.maxGoodPoints; return avg;}
