Java Entropy Calculate entropy(int total, double[] data)

Here you can find the source of entropy(int total, double[] data)

Description

entropy

License

Apache License

Declaration

public static double entropy(int total, double[] data) 

Method Source Code

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

Related

  1. entropy(double[] distribution)
  2. entropy(double[] p)
  3. entropy(double[] vals)
  4. entropy(int hist[])
  5. entropy(int numBins, double[] _f)
  6. entropy(int[] histogram)
  7. longPseudoEntropy()