Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

chi square table in mathematica

I wanted to calculate the probability associated to a given chi-squared value for any given number of degrees of freedom k. I could easily come up with this code:

P[chisquare_, k_] = Manipulate[NIntegrate[PDF[ChiSquareDistribution[k], x], {x, chisquare, Infinity}], {chisquare, 0, 10}, {k, 1, 10}]

but I was wondering: is there any way to do the opposite? I mean having the probability P as an input and getting the associated chi squared value? like if I wanted to compile a chi-squared table such as this https://www.medcalc.org/manual/chi-square-table.php

I tried using Solve but did not accomplish anything, is there an easy way around this?

like image 520
saimon Avatar asked Jul 06 '26 23:07

saimon


1 Answers

You can do the integration with CFD and reverse with Quantile, e.g.

NIntegrate[PDF[ChiSquareDistribution[2], a], {a, 0, 3.0}]

0.77687

p = CDF[ChiSquareDistribution[2], 3.0]

0.77687

Quantile[ChiSquareDistribution[2], p]

Re. your link

enter image description here

Quantile[ChiSquareDistribution[2], 1 - #] & /@ {0.995, 0.975, 0.20, 0.10, 0.05};
SetPrecision[#, If[# < 1, 3, 4]] & /@ %

{0.0100, 0.0506, 3.219, 4.605, 5.991}

like image 180
Chris Degnen Avatar answered Jul 14 '26 07:07

Chris Degnen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!