My entropy calculation method is returning values greater than 1 in strange cases. Any ideas?
<p>My entropy calculation method returns the correct number almost every time. But in a few cases like if the list is <code>{.3333, .3333, .3333, 0, 0}</code> This returns <code>1.584962500621156</code> which is not right.</p>

<p>Here is the code for my entropy calculator:</p>

<pre><code>private double calcEntropySimple(double[] list){
    // Calculate entropy
    double entropy = 0;
    for (int i = 0; i &lt; list.length; i++) {
        if(Double.isNaN(list[i])){
            list[i] = 0;
        }
        if (list[i] &gt; 0) {
            entropy -= list[i] * log2(list[i]);
        }
    }
    return entropy; 
}
</code></pre>

<p>and my <code>log2()</code> method:</p>

<pre><code>private static double log2 (double x) {
   return (Math.log(x)/Math.log(2)+1e-10);
}
</code></pre>