Here you can find the source of entropy(double[] vals)
public static double entropy(double[] vals)
//package com.java2s; //License from project: Open Source License public class Main { public static double entropy(double[] vals) { double entropy = 0; for (double v : vals) { entropy += v * ln(v);//www .ja va 2 s. c o m } return -entropy; } public static double ln(double x) { if (x == 0) { return 0; } return Math.log(x) / Math.log(2); } }