Re: Chi Square Areas
- To: mathgroup at smc.vnet.net
- Subject: [mg110956] Re: Chi Square Areas
- From: Bill Rowe <readnews at sbcglobal.net>
- Date: Wed, 14 Jul 2010 05:35:11 -0400 (EDT)
On 7/13/10 at 5:26 AM, s123 at 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.