Calculating critical values in chi distribution

I am learning about chi tests and I've understood everything so far except how to calculate critical values. I don't want to take number of degrees of freedom and probability of exceeding the critical value(alpha) and look it up in the table. I want to learn how to calculate the critical value.

• As Robert says, trying to compute the critical values by hand is a tall order, unless you've somehow devised a nice method to easily approximate the incomplete gamma function. Nevertheless, you might be interested in looking up the Wilson-Hilferty transformation, which approximates the $\chi^2$ distribution with a normal distribution. – J. M. is a poor mathematician Sep 20 '12 at 18:32
• +1 @J.M. for pointing to a classic paper from the 1930s. Good ideas never die! – Michael Chernick Sep 20 '12 at 19:54

The chi-square distribution with $\nu$ degrees of freedom has cumulative distribution function $$F(x) = 1 - \frac{\Gamma(\nu/2,x/2)}{\Gamma(\nu/2)}\ \text{for} \ x > 0$$ For each positive integer $\nu$ this can be written in terms of powers of $x$, $e^{-x/2}$, and (if $\nu$ is odd) $\text{erf}(\sqrt{x/2})$. The upper-tail critical value at level $\alpha$ is the solution of $F(x) = 1 - \alpha$, while the lower-tail critical value at level $\alpha$ is the solution of $F(x) = \alpha$. This can't generally be done in closed form, but you can use numerical methods.
EDIT: In the case $\nu = 1$, $F(x) = \text{erf}(\sqrt{x/2})$, so the solution of $F(x) = \alpha$ is $x = 2\; (\text{erf}^{-1}(\alpha))^2$.
In the case $\nu = 2$, $F(x) = 1 - e^{-x/2}$ for $x>0$, so the solution of $F(x) = \alpha$ is $x = - 2 \ln(1-\alpha)$.
In the case $\nu = 4$, $F(x) = 1 - (1 + x/2) e^{-x/2}$ for $x > 0$, and the solution of $F(x) = \alpha$ is $x = -2\; \text{LambertW}(-1,-(1-\alpha)/e) - 2$.
• The \Gamma(a,x) function in Robert's answer is known as the incomplete gamma function; one would be hard-pressed to numerically evaluate this function, or its inverse, by hand. – J. M. is a poor mathematician Sep 20 '12 at 18:29