```Date: Mar 28, 2013 2:06 AM
Author: Luis A. Afonso
Subject: Re: Krukal-Wallis by Fisher´s random shuffling

One-way Anova: shuffling, CI and p-value Via Table Items Permutations, without replication and exhaustive, we aim to obtain a Confidence Interval along to p-value for the test statistics H given by _____H = c*sum (Ri(j)^2/n(j) - 3*(N+1)where c = 12/(N*N+1), N the total number of Table items, Ri(j) the sum of ranks concerning the j sample, size n(j).  (One-way Anova).DataThe source-Table is_________1___2___3___4___ ________11___5___6___7___________12___8___9__14___________19__10__13__15___________20__17__16__18___H= 1.606As it was said we intend to get a 5% significance CI, [u, v] that do contain H. The Procedure is:a) at random, without replication the N=20 items are disposed as a pseudo Table, the respective H(g) calculated,b) A very large sample M  of Hs is obtained, thenc) The 0.025, 0.975 quantiles do define the interval bounds u and v.By the other hand the p-value is obtained by computing the proportion of pseudo Tables gives H(g)>H. A comparison with the Chi-squared Distribution is made.ResultsM=400´000, 2 attempts:_________1) 0.234(.027)_8.463(.975)__p-value=0.684_________2) 0.234(.027)_8.529(.975)_________0.679The Chi-squared values leads to [0.216, 9.348], 0.342Luis A. Afonso        REM "GALA-0"REM        CLS : ns = 4REM        DIM along(34), blong(34), clong(34)        DIM W(9001)REM      N(1) = 5: N(2) = 5: N(3) = 5: N(4) = 5        DATA    1,11,12,19,20  FOR i = 1 TO N(1): READ R(i, 1): v = v + 1        along(v) = R(i, 1)        rt(1) = rt(1) + R(i, 1): NEXT iREM        DATA    2,5,8,10,17  FOR i = 1 TO N(2): READ R(i, 2): v = v + 1        along(v) = R(i, 2)        rt(2) = rt(2) + R(i, 2): NEXT iREM        DATA    3,6,9,13,16        FOR i = 1 TO N(3): READ R(i, 3): v = v + 1        along(v) = R(i, 3)        rt(3) = rt(3) + R(i, 3): NEXT iREM        DATA    4,7,14,15,18  FOR i = 1 TO N(4): READ R(i, 4): v = v + 1        along(v) = R(i, 4)        rt(4) = rt(4) + R(i, 4): NEXT iREMFOR k = 1 TO ns: total = total + N(k): NEXT k        FOR k = 1 TO ns    Rin = Rin + rt(k) * rt(k) / N(k): NEXT kREM        ct = 12 / (total * (total + 1))REM        H = ct * Rin - 3 * (total + 1)        LOCATE 4, 20       PRINT USING "SOURCE H=  ##.###   "; H        FOR u = 1 TO total       PRINT USING "###"; along(u); : NEXT u        PRINT : PRINTREMREM        COLOR 14REM        cc(1) = N(1): cc(2) = cc(1) + N(2)  cc(3) = cc(2) + N(3): cc(4) = cc(3) + N(4)        INPUT " How many K_Wallis "; alliREM        FOR rpt = 1 TO alli: vi = 0        REM     refresh        FOR j = 1 TO total        blong(j) = along(j)        NEXT jREMREMLOCATE 14, 50    PRINT USING "############"; alli - rpt    RANDOMIZE TIMER        FOR y = 1 TO total15      ju = INT(total * RND) + 1        IF blong(ju) = -1 THEN GOTO 15        clong(y) = along(ju)REM        blong(ju) = -1        NEXT yREMREMREM  SR(1) = 0: SR(2) = 0: SR(3) = 0: SR(4) = 0        FOR i1 = 1 TO cc(1)        SR(1) = SR(1) + clong(i1)        NEXT i1        FOR i2 = cc(1) + 1 TO cc(2)        SR(2) = SR(2) + clong(i2)        NEXT i2        FOR i3 = cc(2) + 1 TO cc(3)        SR(3) = SR(3) + clong(i3)        NEXT i3        FOR i4 = cc(3) + 1 TO cc(4)        SR(4) = SR(4) + clong(i4)        NEXT i4        si = 0        FOR ti = 1 TO ns        si = si + SR(ti) * SR(ti) / N(ti)        NEXT ti        HH = ct * si - 3 * (total + 1)  IF HH > 1.606 THEN outt = outt + 1 / alli        hh1 = INT(1000 * HH + .5)        IF hh1 > 9000 THEN hh1 = 9000        W(hh1) = W(hh1) + 1REM        NEXT rptREM        cv(1) = .025: cv(2) = 1 - cv(1)        FOR tp = 1 TO 2        suum = 0        FOR i = 0 TO 9000        suum = suum + W(i) / alli        IF suum > cv(tp) THEN GOTO 45        NEXT i45 PRINT USING "#.### #.### "; i / 1000; suum        NEXT tp: COLOR 13: PRINT        PRINT USING " p-value #.###  "; outt        COLOR 7        END
```