code: private double chiSq(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;
  
          // Chi-squared is (Observed - Expected)^2 / Expected
          return 
              ((t[0] - aExp) * (t[0] - aExp) / aExp) +
              ((t[1] - bExp) * (t[1] - bExp) / bExp) +
              ((t[2] - cExp) * (t[2] - cExp) / cExp) +
              ((t[3] - dExp) * (t[3] - dExp) / dExp);
      }
docs: Returns the &Chi;<sup>2</sup> score of the contingency table