EntropySketch implements IEntropy { public double entropy() { double sum = 0.0; for (double d : data) { double tmp = d / (double)count; sum += Math.exp(tmp); } return -(Math.log(sum / (double)data.length) / Math.log(2)); } EntropySketch(int k);  EntropySketch(int k, long seed);  EntropySketch(int k, long seed, Hash hasher); void push(byte[] b, int inc); double entropy();  }
@Test public void testEntropy() { System.out.println("entropy"); EntropySketch sketch = new EntropySketch(10); EntropyExact exact = new EntropyExact(); String s = "hello"; sketch.push(s.getBytes(), 1); exact.push(s.getBytes(), 1); System.out.println("Estimate: " + sketch.entropy()); System.out.println("Exact: " + exact.entropy()); }