Here you can find the source of entropy(int total, double[] data)
public static double entropy(int total, double[] data)
//package com.java2s; //License from project: Apache License public class Main { public static double entropy(int total, double[] data) { double result = 0.0; int len = data.length; for (int i = 0; i < len; i++) { result += -(double) data[i] * log2(data[i] / len); }/*from w ww .j ava 2s .co m*/ return result; } private static double log2(double x) { return Math.log(x) - Math.log(2); } }