This is a question to reflect some very basic understanding of the logic of the chi-square for a planned introductory essay.
[update] I've tried to improve the question with clearer examples and better focusing of the problems upon which I stumbled. It might still be a bit weak but I can't do better at the moment
I'm used to the chi-square as a measure for the deviance from an expected discrete distribution, where the expected frequencies are computed via the marginal frequencies of a crosstab over the empirical data of two categorical items. Let's discuss the 2x2-table here which has one degree of freedom. Assume the marginal row frequencies being [53,47] and the marginal column frequencies being [40,60] giving the expected frequencies as $$ {\bf A}: \text{ expectation for cell-frequencies by equal ratios} \\ \small \begin{array} {r|rr|r} &0&1&all\\ \hline 0&21.2&18.8&40\\ 1&31.8&28.2&60\\ \hline all&53&47&100 \end{array} $$
First I began to think what it means, that the empirical contingency table is bounded by the minimal entry of the marginal frequencies: in this case the cell [0,0] can vary between 0 and 40 only, so we have at most 41 possible outcomes depending on the possible frequencies in that cell. If we assume a normal random process, which generates that frequencies, the (expected) frequency in this cell should be centered around the mean of them 20:
$$ {\bf B}: \text{ means of possible ranges for frequencies in cells}\\ \small \begin{array} {r|rr|r} &0&1&all\\ \hline 0&20&20&40\\ 1&33&27&60\\ \hline all&53&47&100 \end{array} $$
This expectation in cell[0,0] is not equal to the expected frequency of 21.2 . First question: can the latter concept be brought/translated into the first (and standard) one? How could the difference (and relation or possible non-relation) between that two concepts be best explained?
To answer this myself I went back one further step and asked, what does it mean at all to base the chi-square computation on the sample's marginal distribution if this distribution is itself subject of random...
So I generated a "population" data set with N=10000 cases distributed exactly like our table A and took 1000 random samples each with n=100. Over the 1000 samples I've got different marginal frequencies and consequently, each sample has different parameters for its expected frequencies and so for its possible chi-square.
The table of the deviances of the empirical marginal frequencies from the population marginal frequencies was
$$ {\bf C}: \text{ deviations of empirical marginal frequencies from population} \\ \small \begin{array} {r|rrrr} \text{dev } & \text{dev from}& \text{dev from}& \text{dev from}& \text{dev from}\\ \text{value} & 53 & 47 & 40 & 60 \\ \hline -18&0&0&0&1\\ -15&1&1&1&1\\ -14&1&1&0&0\\ -13&2&4&1&1\\ -12&2&6&5&4\\ -11&10&9&5&5\\ -10&8&12&7&14\\ -9&13&15&17&17\\ -8&27&20&21&23\\ -7&34&38&26&31\\ -6&45&35&31&37\\ -5&53&43&62&50\\ -4&46&46&50&49\\ -3&81&67&67&63\\ -2&55&83&84&67\\ -1&85&71&97&80\\ 0&86&86&83&83\\ 1&71&85&80&97\\ 2&83&55&67&84\\ 3&67&81&63&67\\ 4&46&46&49&50\\ 5&43&53&50&62\\ 6&35&45&37&31\\ 7&38&34&31&26\\ 8&20&27&23&21\\ 9&15&13&17&17\\10&12&8&14&7\\11&9&10&5&5\\12&6&2&4&5\\ 13&4&2&1&1\\14&1&1&0&0\\15&1&1&1&1\\18&0&0&1&0 \end{array} $$ The table of occurrences of chi-square for those deviations of the empirical marginal frequencies from the population's is $$ {\bf D}: \text{ deviations of the empirical marginal frequencies} \\ \text{ from that of the population }\\ \text{(in terms of}\ \chi^2\ \text{values)} \\ \begin{array} {r|rr} & & \text{backwards} \\ \chi^2 \text{-value} & \text{freq} & \text{cum freq} \\ \hline 0.0&12.8&100.0\\ 0.5&22.0&87.2\\ 1.0&12.7&65.2\\ 1.5&11.2&52.5\\ 2.0&10.5&41.3\\ 2.5&7.8&30.8\\ 3.0&3.3&23.0\\ 3.5&4.8&19.7\\ 4.0&3.2&14.9\\ 4.5&2.5&11.7\\ 5.0&2.3&9.2\\ 5.5&1.0&6.9\\ 6.0&1.7&5.9\\ 6.5&1.2&4.2\\ 7.0&0.9&3.0\\ 7.5&0.6&2.1\\ 8.0&0.5&1.5\\ 9.0&0.1&1.0\\ 9.5&0.5&0.9\\ 10.0&0.1&0.4\\ 10.5&0.2&0.3\\ 17.0&0.1&0.1 \end{array} $$
I'm stumbling at the simple fact that we compute the chi-square as deviation from an expected frequency - but where the expected frequency is based on an empirical marginal frequency which is itself subject of a random process - and for instance has some confidence-interval when I infer from the sample onto the population.
So - in reverse - having an empirical marginal distribution in our single empirical sample the conclusion to the population's marginal distribution is a matter of confidence intervals. (Is here also a maximum-likelihood aspect lurking around anywhere ?)
This reminds me of the praxis, that we use the sample's variation as estimate of the population's variation-parameter, and do tests based on this assumption.
Q: In the justification/formula for the chi-square-distribution as basis for the significance test - can we find some point, where the randomness of the marginal frequencies is reflected in the formulae?