The G Test in statistics is used to find out the goodness of fit for frequency data. This test attempts to find out any difference between an observed frequency distribution and hypothesized frequency distribution. It can be of 2 types:
1-way tests – Testing a single frequency distribution against an expected distribution
2-way tests – A matrix of observed values are tested for independence
For 1-way test, the formula is:
G = 2 ∑ O ln O/E
Where O and E are the observed and expected numbers respectively, ln stands for natural logarithm and ∑ denotes summation.
For example, considering the different types of leaves:
Using the above formula we get G = 22.58
Here, the Type 1 error is higher and so Williams suggested that G should be divided by a correction factor, q which is equal to 1 + (c2-1)/6 n v where c = no: of categories, n = total no: of observations and v = degrees of freedom ( c-1).