Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
NCTM or The Math Forum.


Luis A. Afonso
Posts:
4,743
From:
LIsbon (Portugal)
Registered:
2/16/05


Three ways to get the Chisquare critical values
Posted:
Sep 25, 2013 5:57 AM


Three ways to get the Chisquare critical values
The main goal is obviously to evaluate how exact is the WilsonHilferty (WH) approximation,Chisquare, 20 d.f. Distribution 2.5% , 97.5% , Critical Values. A second way is to use Monte Carlo, MC simulations: normal X ~ N(0,1):20 by an exact method (BoxMuller algorithm, BM) are simulated the Chisquare obtained by squaring & sum the values. Finally the third method consists in to use the WH formula __r=20, w~ N(0, 1), k=2/(9*r), and Chi2= r*( w*sqrt(k) + (1k) )^ 3 It is evident, for practical uses, the latter way interest: we discard the, say, 20sized normal samples synthesis: one operation is enough to get the Chi2 value. Therefore we ask: how is it the amount of error associated to the approximation? ____ Results: < N222N > Routine (2´000´000 M.C. samples)
__n=20___tables: 9.59, 34.17 ___________9.59______34.12_______MC ___________9.57______34.18_______WH __n=25_________13.12, 40.65 __________13.12______40.64_______ __________13.10______40.64_______ __n=30_________16.79, 46.98 __________16.79______46.96_______ __________16.78______46.98_______
This results are persuasive how accurate is the WH approximation. However the final objective of this confirmation is surely not the futile one to find out Critical Values. To obtain swiftly the ssd (sum of squared deviations) distribution of normal samples should have a rather different worth. Luis A. Afonso REM "N222N" CLS : PRINT DEFDBL AZ COLOR 4 LOCATE 4, 26: PRINT " < N222N > " LOCATE 5, 20 INPUT " degrees of freedom "; n LOCATE 6, 20 INPUT " how many samples "; all REM REM COLOR 7 RANDOMIZE TIMER DIM aw(8001), bw(8001) pi = 4 * ATN(1) REM REM FOR rpt = 1 TO all 14 rpt = rpt + 1 LOCATE 10, 50 PRINT USING "#########"; all  rpt chi1 = 0 FOR t = 1 TO n aa = SQR(2 * LOG(RND)) x = 0 + 1 * aa * COS(2 * pi * RND) chi1 = chi1 + x * x NEXT t REM REM w r = n: k = 2 / (9 * r) aa = SQR(2 * LOG(RND)) w = 0 + 1 * aa * COS(2 * pi * RND) chi2 = r * (w * SQR(k) + (1  k)) ^ 3 REM REM REM IF chi1 > 80 THEN chi1 = 80 IF chi2 > 80 THEN chi2 = 80 ph1 = INT(100 * chi1 + .5) ph2 = INT(100 * chi2 + .5) aw(ph1) = aw(ph1) + 1 bw(ph2) = bw(ph2) + 1 bg = rpt / (all / 10) IF bg <> INT(bg) THEN GOTO 14 REM REM c(1) = .025: c(2) = 1  c(1) FOR ci = 1 TO 2 cc = c(ci): s = 0 FOR t = 0 TO 8000 s = s + aw(t) / rpt IF s > cc THEN GOTO 17 NEXT t 17 PRINT USING " ##.## #.#### "; t / 100; s; NEXT ci: PRINT : PRINT c(1) = .025: c(2) = 1  c(1) FOR ci = 1 TO 2 cc = c(ci): s = 0 FOR t = 0 TO 8000 s = s + bw(t) / rpt IF s > cc THEN GOTO 18 NEXT t 18 PRINT USING " ##.## #.#### "; t / 100; s; NEXT ci: PRINT : PRINT NEXT rpt REM END



