Java Entropy Calculate calcEntropyOfDiscreteProbDist(Double[] probDist)

Here you can find the source of calcEntropyOfDiscreteProbDist(Double[] probDist)

Description

calc Entropy Of Discrete Prob Dist

License

Open Source License

Declaration

public static double calcEntropyOfDiscreteProbDist(Double[] probDist) 

Method Source Code

//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;
    }
}

Related

  1. computeEntropy(int pos, int neg)
  2. discreteEntropy(int[] sequence, int numStates)
  3. discretiseMaxEntropy(double data[], int numBins)
  4. entropy(byte[] f)