I understand the classcial $\chi^2$ "goodness of fit" test used in Statistics, in which we compute $\sum_{i=1}^n \frac{(O_i - E_i)^2}{E_i}$ and, by comparing this quantity to a value found in a table of $\chi^2$ law (with a given risk $\alpha = 5\%$ for example), we decide if we should or not accept the hypothesis that the sample is likely to be an observation or not of a given distribution.
But I haven't found a good precise proof online yet, that shows that it's not only a good "recipe", but also has a strict proof, using probability theory (I know it exists, but I haven't found one yet).
Do you know a good detailed proof?