Re: Chi squared -> p-value - Any formula??
- From: "Dave (from the UK)" <see-my-signature@xxxxxxxxxxxxx>
- Date: Sun, 29 Jul 2007 10:10:34 +0100
Ray Koopman wrote:
My favorite simple approximation for the standard normal cdf is
1/(1 + Exp[-.496937z*Sqrt[z^2 + 10.28]]),
for which the absolute error is < 1.58*10^-4.
The corresponding approximation for the complementary cdf (i.e.,
the upper tail area) of a chi-square variable with 1 d.f. is
2/(1 + Exp[.496937*Sqrt[x(x + 10.28)]).
Thanks for that Ray - it was most helpful.
The claimed accuracy of the approximation for the standard normal cdf (< 1.58*10^-4) is somewhat better than that of the approximation Ken gave, and is also simpler to type, so I decided to try your approximation.
I did some checks of your formula in Mathematica and found largest *absolute* error of the p-value is 0.0003147. (I tested that for chi-squared values in the range 0 to 40 in steps of 0.00001)
For chi-squared in the range 0 to 6.63489 (p-values 1.0 down to 0.01), the maximum fractional error in the p-values was 2.91%.
Extending its range somewhat more, with chi-squared to 10.827566 (p-values of 1.0 down to 0.001) gave an error in the p-values of <= 9.18 %, which is good enough for me.
Just for completeness, I tested it to p-values down to 0.0001 (chi-squared up to 15.136705) at which point the error in p-values is quite large (16.9%), but realistically for me, I'm only really interested in p-values down to 0.005 or so, where the error is 4.56% or less.
So far I've only tested a Mathematica approximation, but assuming Tcl's maths functions are not broken, it should give similar results in Tcl.
BTW, the reason for using Tcl is that I have a program that was originally written in that. Its not an ideal language for maths stuff, but the main program is a chess database, not a maths package.
--
Dave (from the UK)
Please note my email address changes periodically to avoid spam.
It is always of the form: month-year@xxxxxxxxxxxx
Hitting reply will work for a few months only - later set it manually.
http://chessdb.sourceforge.net/ - a Free open-source Chess Database
.
- Follow-Ups:
- Re: Chi squared -> p-value - Any formula??
- From: Ray Koopman
- Re: Chi squared -> p-value - Any formula??
- References:
- Chi squared -> p-value - Any formula??
- From: Dave (from the UK)
- Re: Chi squared -> p-value - Any formula??
- From: Ray Koopman
- Chi squared -> p-value - Any formula??
- Prev by Date: Re: Chi squared -> p-value - Any formula??
- Next by Date: Re: No control population
- Previous by thread: Re: Chi squared -> p-value - Any formula??
- Next by thread: Re: Chi squared -> p-value - Any formula??
- Index(es):
Relevant Pages
|