// returns 0 for identical, 1 for completely different
static double chiSquared_histogramsWithSum1(Map map1, Map map2) {
if (empty(map1) || empty(map2)) ret Double.NaN;
double sum = 0;
for (A key : joinSets(keys(map1), keys(map2))) {
double mi = or0(map1.get(key));
double ni = or0(map2.get(key));
double item = sqr(ni-mi)/(mi+ni);
ifdef chiSquared_histogramsWithSum1_debug
printVars_str(+key, +mi, +ni, +item);
endifdef
sum += item;
}
ret sum/2;
}