I am building a small library for computing information retrieval metrics for classifiers (precision, recall, f1, accuracy, whatever). Typically each metric is built by calculating a single value for each object being classified (each metric will have its own formula there) and then calculating a single value (an average) aggregating all those single values; hence a mapper and a reducer.
With little formal training in numeric stability, I wonder what would be the most numerically stable way to calculate the average, and what might be the most interesting trade-offs between stability, avoidance of overflow, and computational complexity (performance).
Also any reference to a mathematical reading in this vein would be entirely welcome, for this, as well as for as similar future cases.
Thanks in advance!