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 ) { // Maybe this should just be a return. 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 .