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