http://qs321.pair.com?node_id=1017451


in reply to calculate Chi-Square test

To add to blue_cowdawg's advice, if you need to roll your own, what you are seeking is the probability density function of the chi-squared distribution, which is given here where x is the chi-square value and k is the number of degrees of freedom, and you will need to include values from the Gamma function, which has a closed form solution for half-integer value (i.e. k/2).