2
$\begingroup$

I am trying to reproduce the (upper-tail) critical values of chi-square distribution with ν degrees of freedom as reported here. As a test I looked at $\nu=2$ and the probability $0.99$.

As far as I can tell, in Mathematica the ChiSquare distribution is implemented in ChiSquareDistribution, so here is what I tried to do to find the value:

NIntegrate[PDF[ChiSquareDistribution[2], x], {x, 99/100, Infinity}]

However, this gives 0.609571. Do I need to scale this value to get the desired result?

$\endgroup$
4
  • 4
    $\begingroup$ Quantile[ChiSquareDistribution[2], .99] or NSolve[CDF[ChiSquareDistribution[2], t] == 99/100, t, Reals]? $\endgroup$
    – kglr
    Commented Dec 1, 2017 at 17:33
  • 5
    $\begingroup$ InverseCDF[ChiSquareDistribution[2],99/100] as well. $\endgroup$
    – chuy
    Commented Dec 1, 2017 at 17:45
  • 1
    $\begingroup$ Or working from the PDF: FindRoot[Integrate[PDF[ChiSquareDistribution[2], x], {x, 0, xf}] == 0.99, {xf, 1}] // Quiet` or Assuming[xf > 0, Solve[Integrate[PDF[ChiSquareDistribution[2], x], {x, 0, xf}] == 0.99, xf]] // Quiet` $\endgroup$
    – Bob Hanlon
    Commented Dec 1, 2017 at 19:23
  • 1
    $\begingroup$ For your question "Do I need to scale this value to get the desired result?", the answer is "No. You've formulated the statement incorrectly to obtain the desired result." To obtain 0.99 you'd need to use NIntegrate[PDF[ChiSquareDistribution[2], x], {x, 0, 9.21034}]. To obtain the desired value (9.21034) you'd need to follow any of the above comments. $\endgroup$
    – JimB
    Commented Dec 2, 2017 at 1:55

1 Answer 1

3
$\begingroup$
N @ Quantile[ChiSquareDistribution[2], 99/100] 

9.21034

t /.  First@ NSolve[CDF[ChiSquareDistribution[2], t] == 99/100, t, Reals]

9.21034

Or, modifying the formulation in OP:

t /. First @ NSolve[Integrate[PDF[ChiSquareDistribution[2], x], {x, 0, t}, 
     Assumptions -> Element[t, Reals]] == 99/100, t, Reals]

9.21034

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.