### Question:
MyArrays { public static float entropy(float[] c) { float e = 0.0f; for(int i=0;i<c.length;i++){ if(c[i]!=0.0&&c[i]!=1){ e -= c[i]*Math.log(c[i]); } } return e; }  static int addBest(float[] scores, Object[] predList, float score, Object pred); static TreeMap<Integer, Integer> countFrequency(TIntIntHashMap freqmap); static float[][] histogram(float[] count, int nbin); static void normalize(float[] c); static void normalize2Prop(float[] c); static int[] sort(float[] c); static int[] getTop(float[] c, float thres, boolean r); static void set(float[] c, int[] idx, float v); static void trim(float[] c, float v); static int sum(int[] c); static int[] accumulate(int[] c); static float viarance(float[] c); static float entropy(float[] c); static float entropy(int[] c); static float average(float[] c); static float sum(float[] c); static int countNoneZero(float[] c); static boolean[] getNoneZeroIdx(float[] c); static int[] string2int(String[] c); static String[] int2string(int[] c); static int[] sort(TIntFloatHashMap data); static int[][] getTop(TIntFloatHashMap data, float thres); static void setZero(TIntFloatHashMap data, int[] idx); static int[] trim(TIntFloatHashMap data, float v); static void trim(HashSparseVector c, float v);  }### Answer:
@Test public void testentropy() { int[] w; float[] ww; float e; w= new int[]{ 1, 2, 3, 4, 0, 0, 0 }; e = MyArrays.entropy(w); System.out.print(e + " "); ww= new float[]{ 1, 0, 0, 0, 0, 0, 0 }; e = MyArrays.entropy(ww); System.out.print(e + " "); System.out.println(); TIntArrayList www = new TIntArrayList(); for(int i=0;i<100;i++){ www.add(1); w = www.toArray(); e = MyArrays.entropy(w); System.out.print(e + " "); System.out.println(e/w.length); } System.out.println(); ww= new float[]{ 0.5f, 0.5f }; e = MyArrays.entropy(ww); System.out.print(e + " "); }