static Average multiSetAverage(MultiSet ms) { new Average a; for (key : keys(ms)) a.add(toDouble(key), ms.get(key)); ret a; }