code: private double logLikelihood(int[] contingencyTable) {
          // Rename for short-hand convenience
          int[] t = contingencyTable;
          int col1sum = t[0] + t[2];
          int col2sum = t[1] + t[3];
          int row1sum = t[0] + t[1];
          int row2sum = t[2] + t[3];
          double sum = row1sum + row2sum;
          
          // Calculate the expected values for a, b, c, d
          double aExp = (row1sum / sum) * col1sum;
          double bExp = (row1sum / sum) * col2sum;
          double cExp = (row2sum / sum) * col1sum;
          double dExp = (row2sum / sum) * col2sum;
  
          return 2 *
              ((t[0] * Math.log(t[0] - aExp))  +
               (t[1] * Math.log(t[1] - bExp))  +
               (t[2] * Math.log(t[2] - cExp))  +
               (t[3] * Math.log(t[3] - dExp)));
      }
docs: Returns the log-likelihood score of the contingency table