Here you can find the source of calcEntropyOfDiscreteProbDist(Double[] probDist)
public static double calcEntropyOfDiscreteProbDist(Double[] probDist)
//package com.java2s; //License from project: Open Source License public class Main { public static double calcEntropyOfDiscreteProbDist(Double[] probDist) { double entropy = 0.0; for (double x : probDist) { entropy -= x * Math.log(x) / Math.log(2); }//w w w. j av a 2 s. c om return entropy; } }