How the χ² (chi-square) distribution is built

χ² Builder

Draw values one at a time from the standard normal distribution, square them, and stack them up. The distribution of that running total is the χ² distribution. Pick a degrees of freedom (df) below and start drawing.

Samples completed: 0 Current df: 2

1. Draw a Z

Draw a value from the standard normal distribution (mean 0, SD 1)

2. Square it and stack

Squaring a Z always gives a value ≥ 0, and stacking the squares gives the χ² statistic

χ² = —

3. Growing histogram

Completed samples pile up and trace out the χ² distribution (solid line)

From the lab (df = 2): the school × artifact-type comparison gave χ² = 307.4. That's far beyond the histogram's range (0–22) below, out in a tail so thin that p is essentially zero.

The math

This is the real-data version of the Z's you've been squaring and stacking above.

Expected count for row i, column j Eij=Cj×RiN C = column total (that school’s items) · R ÷ N = the row’s share of the grand total. If school made no difference, each school gets the overall share of its own items.
Pearson residual rij=Oij−EijEij This is the piece that behaves like one of the Z's above, once N is reasonably large.
χ² statistic χ2=∑i,j(Oij−Eij)2Eijdf=(r−1)(c−1) Square and sum the residuals above, cell by cell. It is the same squaring-and-summing this page does with Z's. One catch is that the lab table has 6 residuals but df = 2, because once the row and column totals are fixed only (r−1)(c−1) = 2 cells are free to vary. So compare the lab's χ² with the df = 2 curve, not df = 6.