Wolfram Alpha:

```χ2 Goodness of Fit
------------------

Goodness of fit involves the comparison between an observed
frequency distribution and the corresponding values of a
theoretical frequency distribution. The test is appropriate when:

- The sampling method is simple random sampling.
- The population is at least 10 times as large as the sample.
- The variable under study is categorical.
- The expected value of the number of sample observations in
each level of the variable is at least 5.

χv2 = Σ[Oi - Ei)2/Ei]

where:

k = number of levels of the categorical variable.
v = degrees of freedom = k - 1
Oi = Observed frequency of observations in level i
Ei = npi = Expected frequency of observations in level i
pi = proportion of observations in level i

Example
-------

A company claims that 30% of baseball cards are rookies, 60%
veterans, and 10% are All-Stars.  The cards are sold in packages
of 100.  Suppose a randomly-selected package of cards has 50
rookies, 45 veterans, and 5 All-Stars. Is this consistent with the
company's claim? Use a 0.05 level of significance?

- H0: The proportion of rookies, veterans, and All-Stars is 30%,
60% and 10%, respectively.
- H1: At least one of the proportions in the null hypothesis is
false.

v = k - 1 = 3 - 1 = 2

Ei = npi
E1 = 100 * 0.30 = 30
E2 = 100 * 0.60 = 60
E2 = 100 * 0.10 = 10

χ2 = Σ[(Oi - Ei)2/Ei]

= [(50 - 30)2/30 ] + [(45 - 60)2/60] + [(5 - 10)2/10]

= (400/30) + (225/60) + (25/10) = 13.33 + 3.75 + 2.50 = 19.58

From tabless, the p-value corresponding to 19.58  = 0.0001.
Therefore we can reject H0```