# Is Pearson's chi-squared test of independence conditional on marginal distributions?

The Wikipedia page on Pearson's chi-squared test states that a difference to Fisher's exact test is that the latter makes the "assumption of fixed marginal distributions". I assume that applies to the use of chi-squared as a test of independence, because that is what Fisher's exact test does.

However, the description of the chi-squared test for independence clearly shows that it is a goodness-of-fit test which compares the observed joint distribution $$O_{i,j}$$ to the one expected under independence from the marginal distributions, $$E_{i,j} = N p_{i\cdot} p_{\cdot j},$$ which in turn are estimated from the observed marginals, $$p_{i\cdot} = \frac{O_{i\cdot}}{N} = \frac1N \sum_j O_{ij},$$ and correspondingly for $$p_{\cdot j}$$. As far as I can see that means that the test is conditional on given $$N$$, $$p_{i\cdot}$$, and $$p_{\cdot j}$$.

Can someone clear this up? Maybe Wikipedia is simply wrong?

With the chi-square test, in contrast, only the total number of counts, $$N$$, is taken as pre-specified. Although you do observe particular row totals and column totals, those are not fixed by design. Unlike with pre-specified row and column totals, the statistical test must take into account the sampling variability that might have led to those observed row and column totals, given only the toal number of counts.