Java Entropy Calculate entropy(double[] vals)

Here you can find the source of entropy(double[] vals)

Description

entropy

License

Open Source License

Declaration

public static double entropy(double[] vals) 

Method Source Code

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

Related

  1. discreteEntropy(int[] sequence, int numStates)
  2. discretiseMaxEntropy(double data[], int numBins)
  3. entropy(byte[] f)
  4. entropy(double[] distribution)
  5. entropy(double[] p)
  6. entropy(int hist[])
  7. entropy(int numBins, double[] _f)
  8. entropy(int total, double[] data)
  9. entropy(int[] histogram)