src/main/java/com/xceptance/neodymium/visual/ai/image/HistogramStatistics.java
/**
     * Calculate entropy value.
     * 
     * @param values
     *            Values.
     * @return Returns entropy value of the specified histogram array.
     */
Calculate entropy value.

@param values
Values.
@return Returns entropy value of the specified histogram array.
Calculate entropy value . @param values Values . @return Returns entropy value of the specified histogram array .
public static double Entropy(int[] values)
    {
        int n = values.length;
        int total = 0;
        double entropy = 0;
        double p;
        for (int i = 0; i < n; i++)
        {
            total += values[i];
        }
        if (total != 0)
        {
            for (int i = 0; i < n; i++)
            {
                p = (double) values[i] / total;
                if (p != 0)
                    entropy += (-p * (Math.log10(p) / Math.log10(2)));
            }
        }
        return entropy;
    }
public static double Entropy ( int [ ] values ) { int n = values . length ; int total = 0 ; double entropy = 0 ; double p ; for ( int i = 0 ; i < n ; i ++ ) { total += values [ i ] ; } if ( total != 0 ) { for ( int i = 0 ; i < n ; i ++ ) { p = ( double ) values [ i ] / total ; if ( p != 0 ) entropy += ( - p * ( Math . log10 ( p ) / Math . log10 ( 2 ) ) ) ; } } return entropy ; }
Calculate entropy value.
Calculate entropy value .
// calculate total amount of hits // for all values // get item's probability // calculate entropy