Here you can find the source of entropy(int hist[])
Parameter | Description |
---|---|
hist | the hist |
static float entropy(int hist[])
//package com.java2s; public class Main { /**//from w w w.j a va 2 s . c o m * Entropy. * * @param hist * the hist * @return the float */ static float entropy(int hist[]) { int n = hist.length; int t = 0; for (int i = 0; i < n; i++) t += hist[i]; float h = 0; // System.out.print("[ " + hist[0] + "," + hist[1] + "] -> "); for (int i = 0; i < n; i++) { if (hist[i] != 0) { float f = (float) hist[i] / (float) (t); h -= Math.log(f) * f; } } // System.out.println("" + h); return h; } }