Computes an average correctly.