A goodness-of-fit test is conducted to determine whether the observed frequency values are statistically similar to the frequencies expected for the dataset. Suppose the expected frequencies for a dataset are equal such as when predicting the frequency of any number appearing when casting a die. In that case, the expected frequency is the ratio of the total number of observations (n) to the number of categories (k).
Hence, the expected frequency of any number appearing when casting a die will be 1/6.
However, suppose the expected frequencies of the dataset are unequal; the expected frequency is obtained by multiplying the total number of observations n and the probability p for the category.