$
\chi^2 = \sum_{i = 1}^{k}\frac{(o_i - e_i)^2}{e_i}
$
To determine if a [[Population|population]] [[Probability Distribution|distribution]] follows a specific theoretical distribution, setup a right-tailed [[Hypothesis Test|hypothesis test]] on the deviation between the theoretical and empirical distributions, with the deviation between the theoretical distribution and the [[Sample|sample]] [[Frequency Distribution|frequency distribution]] $\chi^2$ as the test [[Statistic|statistic]].
Divide the population into a series of [[Class|classes]] such that the expected frequency of each class $e_i$ is greater than $5$ for the normal approximation to kick in.
Establish the [[Null Hypothesis|null hypothesis]] that the population perfectly follows the theoretical distribution. Note that since the [[Chi-Square Distribution|chi-square distribution]] is entirely to the right of the $x$ axis, this is a right-tailed test:
$
\begin{align*}
&H_0: \chi^2 = 0 \\
&H_1: \chi^2 > 0
\end{align*}
$
Assuming that the null hypothesis holds true, each part of $\chi^2$, $\frac{(o_i - e_i)^2}{e_i} = \frac{(e_i - e_i)^2}{e_i} = 0$, $\frac{o_i - e_i}{\sqrt{e_i}}$ has a mean of $0$. Since each frequency represents a [[Binomial Random Variable|proportion]], for sufficiently large [[Count|sample sizes]], $o_i$ is [[Continuous Approximation of Discrete Distributions|approximately normally distributed]], justifying the use of the [[Chi-Square Distribution|chi-square distribution]] as $(o_i - e_i)^2$ becomes the square of a [[Normal Distribution|normal distribution]].
Use the [[Chi-Square Distribution|chi-square distribution]] with $(n - 1)$ degrees of freedom, removing an additional degree of freedom for each parameter [[Estimator|estimated]].
| Distribution | Estimated Variables | Degrees of Freedom |
| -------------------------------------------------------------------------------------------------------------------------------- | -------------------------------- | ------------------ |
| [[Normal Distribution\|Normal]] | [[Mean]], [[Standard Deviation]] | $n - 3$ |
| [[Binomial Random Variable|Binomial]], [[Geometric Distribution\|Geometric]] [[Negative Binomial Distribution\|Negative Binomial]] | Proportion | $n - 2$ |
| [[Poisson Distribution\|Poisson]], [[Exponential Random Variable|Exponential]] | $\lambda$ | $n - 2$ |
Reject $H_0$ if $t \ge \chi^2_{\alpha}(k)$.
If the null hypothesis is rejected, then the theoretical distribution is not a good fit for the population.