LogLikelihood { public static double entropy(long... elements) { long sum = 0; double result = 0.0; for (long element : elements) { Preconditions.checkArgument(element >= 0); result += xLogX(element); sum += element; } return xLogX(sum) - result; } private  LogLikelihood(); static double entropy(long... elements); static double logLikelihoodRatio(long k11, long k12, long k21, long k22); static double rootLogLikelihoodRatio(long k11, long k12, long k21, long k22); static List<ScoredItem<T>> compareFrequencies(Multiset<T> a,
                                                           Multiset<T> b,
                                                           int maxReturn,
                                                           double threshold);  }
@Test public void testEntropy() throws Exception { assertEquals(1.386294, LogLikelihood.entropy(1, 1), 0.0001); assertEquals(0.0, LogLikelihood.entropy(1), 0.0); try { LogLikelihood.entropy(-1, -1); fail(); } catch (IllegalArgumentException e) { } }