} }
  public static void normalize(double[] doubles) throws Exception {    double sum = 0;    for (int i = 0; i < doubles.length; i++)      sum += doubles[i];    if (Double.isNaN(sum)) {      throw new Exception("Array contains NaN - can't normalize");    }    if (sum != 0)      for (int i = 0; i < doubles.length; i++)	doubles[i] /= sum;  }