public static double info(int counts[]){
  int total=0;
  double x=0;
  for (  int count : counts) {
    x-=xlogx(count);
    total+=count;
  }
  return x + xlogx(total);
}

public static double info ( int counts [ ] ) { int total = 0 ; double x = 0 ; for ( int count : counts ) { x -= xlogx ( count ) ; total += count ; } return x + xlogx ( total ) ; }
computes entropy for an array of integers .
