From: Norbert Marxer on
On Jul 10, 10:01 am, Steve <s...(a)epix.net> wrote:
> Hi,
>
> Can someone show me how to get Mathematica to provide the areas to the
> right of a given critical value of the Chi Square distribution ?
>
> The table entries shown athttp://www2.lv.psu.edu/jxm57/irp/chisquar.html
> are what I need to compute.
>
> For example, given 8 degrees of freedom and a probability value of
> 0.05 the result would be 15.51.
>
> And given 5 degrees of freedom with probability 0.1 the result is
> 9.24.
>
> How can I produce these results in Mathematica ?
>
> Thanks so much.

Hello

You can use the built-in functions:

InverseCDF[ChiSquareDistribution[8], 0.95]
InverseCDF[ChiSquareDistribution[5], 0.9]

which will give you the numbers 15.5073 and 9.23636.

But note, these numbers represent the critical values! The areas (to
the right) are given by 0.05 (5%) and 0.10 (10%) respectively.

Best Regards
Norbert Marxer

From: Steve on
On Jul 11, 6:21 am, Norbert Marxer <mar...(a)mec.li> wrote:
> On Jul 10, 10:01 am, Steve <s...(a)epix.net> wrote:
>
>
>
>
>
> > Hi,
>
> > Can someone show me how to get Mathematica to provide the areas to the
> > right of a given critical value of the Chi Square distribution ?
>
> > The table entries shown athttp://www2.lv.psu.edu/jxm57/irp/chisquar.html
> > are what I need to compute.
>
> > For example, given 8 degrees of freedom and a probability value of
> > 0.05 the result would be 15.51.
>
> > And given 5 degrees of freedom with probability 0.1 the result is
> > 9.24.
>
> > How can I produce these results in Mathematica ?
>
> > Thanks so much.
>
> Hello
>
> You can use the built-in functions:
>
> InverseCDF[ChiSquareDistribution[8], 0.95]
> InverseCDF[ChiSquareDistribution[5], 0.9]
>
> which will give you the numbers 15.5073 and 9.23636.
>
> But note, these numbers represent the critical values! The areas (to
> the right) are given by 0.05 (5%) and 0.10 (10%) respectively.
>
> Best Regards
> Norbert Marxer- Hide quoted text -
>
> - Show quoted text -

Thanks to everyone who replied. 15 minutes after posting my question,
I figured it out on my own, albeit a not too elegant solution.

Norbert provided a particularly elegant solution and also pointed out
a small inconsistency in my question. The values I needed returned
were the critical values not the areas as I had stated at the
beginning of my post.

Below is a parameter-consistent comparison of my solution and
Norbert's.

Thanks again to all,
Steve

DOF = 8;
confidence = .90;
p = (1 - confidence)/2
ChiPDF = PDF[ChiSquareDistribution[DOF], x]
Plot[ChiPDF, {x, 0, 50}]
guessvalue = 2.5;
stevesolution =
FindRoot[NIntegrate[ChiPDF, {x, CriticalValue, Infinity}] ==
p, {CriticalValue, guessvalue}];
stevesolution = stevesolution[[1, 2]]
norbertsolution =
InverseCDF[ChiSquareDistribution[DOF], confidence + p]
difference = stevesolution - norbertsolution



From: Bill Rowe on
On 7/13/10 at 5:26 AM, s123(a)epix.net (Steve) wrote:

>Norbert provided a particularly elegant solution and also pointed
>out a small inconsistency in my question. The values I needed
>returned were the critical values not the areas as I had stated at
>the beginning of my post.

>Below is a parameter-consistent comparison of my solution and
>Norbert's.

>DOF = 8;
>confidence = .90;
>p = (1 - confidence)/2
>ChiPDF = PDF[ChiSquareDistribution[DOF], x]
>Plot[ChiPDF, {x, 0, 50}]
>guessvalue = 2.5;
>stevesolution =
>FindRoot[NIntegrate[ChiPDF, {x, CriticalValue, Infinity}] ==
>p, {CriticalValue, guessvalue}];
>stevesolution = stevesolution[[1, 2]]
>norbertsolution =
>InverseCDF[ChiSquareDistribution[DOF], confidence + p]
>difference = stevesolution - norbertsolution

In case you are not aware of it, the difference between a
solution using FindRoot and NIntegrate and one using either
InverseCDF or Quantile is due to small differences in rounding
resulting from different algorithms and machine precision
numbers. FindRoot and NIntegrate are general purpose root
finding and numerical integration tools. Quantile and InverseCDF
are more specialized and are certain to be more optimized for
doing this particular computation. Consequently, these will
execute faster and will yield better results.