code: public static double normalizeLogProps(double[] logProps) {
          double logPropSum = DoubleArrays.logSum(logProps);
          if (logPropSum == Double.NEGATIVE_INFINITY) {
              double uniform = FastMath.log(1.0 / (double)logProps.length);
              for (int d = 0; d < logProps.length; d++) {
                  logProps[d] = uniform;
              }
          } else if (logPropSum == Double.POSITIVE_INFINITY) {
              int count = DoubleArrays.count(logProps, Double.POSITIVE_INFINITY);
              if (count == 0) {
                  throw new RuntimeException("Unable to normalize since sum is infinite but contains no infinities: " + Arrays.toString(logProps));
              }
              double constant = FastMath.log(1.0 / (double) count);
              for (int d=0; d<logProps.length; d++) {
                  if (logProps[d] == Double.POSITIVE_INFINITY) {
                      logProps[d] = constant;
                  } else {
                      logProps[d] = Double.NEGATIVE_INFINITY;
                  }
              }
          } else {
              for (int d = 0; d < logProps.length; d++) {
                  logProps[d] -= logPropSum;
                  assert(!Double.isNaN(logProps[d]));
              }            
          }
          return logPropSum;
      }
docs: In the log-semiring, normalize the proportions and return their sum.