# Where do chi squared p-value lookup tables come from?

I'm doing a lot of labs in science and my teacher always wants us to find the chi-squared values of our data and find the probability of that occurring from a lookup table. Where do these probabilities come from in the lookup table? Is there a function or functions that output these numbers?

• the lookup tables your teacher mentions are the distribution tables. For example, you can get your p value for z score from normal distribution table while chi squared p-values would come from corresponding chi squared distribution. There are lots of online websites that replaced the traditional tables. for example see here – V. Aslanyan Jan 24 at 5:19

## 1 Answer

A little about statistics and statistical tests.

When you use the data to compute these chi-square values, we idealize whatever you compute as coming from a probability distribution. The distribution is called the chi-square distribution.

The chi-square distribution depends on a parameter called "the degrees of freedom". Since probability distributions are just functions (you know about functions), I can plot them. I've plotted the chi-square under a couple of degrees of freedom below.

[ Now, onto p-values. Let's say you conduct your experiment and get a chi-square value. You go to your table and find the corresponding p-value. Those p-values in those tables are what we call "tail probabilities". So for example, let's say your experiment has 2 degrees of freedom (corresponding to the top left picture). You get a chi-square value of 2. Then, your p-value is the area under the curve to the right of 2 (the shaded region).

What those tables do is tell you the area under the curve for a variety of chi-square values. We obtain the values in the table by computing the area under the curve. It is easier to compute the areas under the curves once and put them in a table rather than have you compute the areas yourself, hence why you look up values in tables.

### Math, if you are interested...

The function for the chi-square distribution is

$$f(x) = \begin{cases} \dfrac{x^{k/2 - 1}e^{-x/2}}{2^{k/2} \Gamma(k/2)} \quad x>0 \\ 0 \qquad\qquad \text{else} \end{cases}$$

Here, $$k$$ is the degrees of freedom. Suppose you get a chi-square value of $$\chi$$. Then the p-value is

$$\lim_{s\rightarrow \infty} \int_{\chi}^s f(x) \, dx$$

We know this integral converges, and that it is less than 1 unless $$\chi=0$$. The table is created by computing this integral for various $$k$$ and $$\chi$$.