From chi-square statistic to p-value
The p-value for a chi-square test is the probability of observing a test statistic at least as extreme as the calculated value, assuming the null hypothesis is true. It is computed from the upper tail of the chi-square distribution using the regularized incomplete gamma function.
A smaller p-value indicates stronger evidence against the null hypothesis. The critical value at a given significance level is the chi-square value that produces exactly that p-value.
p = 1 − P(df/2, χ²/2)
P-value from the regularized incomplete gamma function.