Goodness of fit

Goodness of fit means how well a statistical model fits a set of observations. Measures of goodness-of-fit typically summarize the discrepancy between observed values and the values expected under the model in question. Such measures can be used in statistical hypothesis testing, e.g. to test for normality of residuals, to test whether two samples are drawn from identical distributions (see Kolmogorov-Smirnov test), or whether outcome frequencies follow a specified distribution (see Pearson's chi-square test).

Example
The chi-square statistic is a sum of differences between observed and expected outcome frequencies, each squared and divided by the expectation:


 * $$ \chi^2 = \sum {(O - E)^2 \over E}$$

where:
 * O = an observed frequency
 * E = an expected (theoretical) frequency, asserted by the null hypothesis

The resulting value can be compared to the chi-square distribution to determine the goodness of fit.