public static double entropy(double[] vector){
  if (vector == null)   return 0;
 else   if (vector.length < 1)   return 0;
 else {
    double ret=0;
    for (    double d : vector)     ret+=d * Math.log(d);
    return ret;
  }
}

public static double entropy ( double [ ] vector ) { if ( vector == null ) return 0 ; else if ( vector . length < 1 ) return 0 ; else { double ret = 0 ; for ( double d : vector ) ret += d * Math . log ( d ) ; return ret ; } }
this returns the entropy ( information gain , or uncertainty of a random variable ) .
