public static void normalize(double[] doubles,double sum){
  if (Double.isNaN(sum)) {
    throw new IllegalArgumentException("Can't normalize array. Sum is NaN.");
  }
  if (sum == 0) {
    throw new IllegalArgumentException("Can't normalize array. Sum is zero.");
  }
  for (int i=0; i < doubles.length; i++) {
    doubles[i]/=sum;
  }
}

public static void normalize ( double [ ] doubles , double sum ) { if ( Double . isNaN ( sum ) ) { throw new IllegalArgumentException ( "Can't normalize array. Sum is NaN." ) ; } if ( sum == 0 ) { throw new IllegalArgumentException ( "Can't normalize array. Sum is zero." ) ; } for ( int i = 0 ; i < doubles . length ; i ++ ) { doubles [ i ] /= sum ; } }
normalizes the doubles in the array using the given value .
