Calculates the G-test for a contingency table. The formula for the
G-test statistic is
2 * sum[fij log [f ij/f-hatij]]
where f ij is the ith by jth cell in the table and f-hatij is the
expected value of that cell. If an expected-value-matrix is supplied,
it must be the same size as table and it is used for expected values,
in which case the G-test is a test of goodness-of-fit. If the
expected value matrix is unsupplied, it is calculated from using the
formula
e ij = [fi* * f *j] / f**
where f i*, f*j and f ** are the row, column and grand totals
respectively. In this case, the G-test is a test of independence. The degrees of freedom is the same as for the chi-square statistic and the significance is obtained by comparing