code: @SuppressWarnings("WeakerAccess")
      public static double compareChi2(Histogram dist1, Histogram dist2) {
          if (!dist1.getClass().equals(dist2.getClass())) {
              throw new IllegalArgumentException(String.format("Must have same class arguments, got %s and %s",
                      dist1.getClass(), dist2.getClass()));
          }
  
          long[] k1 = dist1.getCounts();
          long[] k2 = dist2.getCounts();
  
          int n1 = k1.length;
          if (n1 != k2.length ||
                  dist1.lowerBound(0) != dist2.lowerBound(0) ||
                  dist1.lowerBound(n1 - 1) != dist2.lowerBound(n1 - 1)) {
              throw new IllegalArgumentException("Incompatible histograms in terms of size or bounds");
          }
  
          double[][] count = new double[2][n1];
          for (int i = 0; i < n1; i++) {
              count[0][i] = k1[i];
              count[1][i] = k2[i];
          }
          return llr(count);
      }
docs: Use a log-likelihood ratio test to compare two distributions.
  With non-linear histograms that have compatible bin boundaries,
  all that we have to do is compare two count vectors using a
  chi^2 test (actually a log-likelihood ratio version called a G-test).
  
  @param dist1 First distribution (usually the reference)
  @param dist2 Second distribution to compare (usually the test case)
  @return A score that is big when dist1 and dist2 are discernibly different.
  A small score does not mean similarity. Instead, it could just mean insufficient
  data.