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


KolmogorovSmirnovLilliefors Test statistics
Posted:
Sep 16, 2012 5:57 PM


KolmogorovSmirnovLilliefors Test statistics
The maxima and secondary maxima discrepancy from Normal data: Critical Values.
______________________________________________
Lilliefors Test Table (1million samples/size) The First and Second maximum differences between the Normal Distribution values and sample size n cumulative fractiles. M.A. Molin & Abdil values.
citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.64.5753&am
Fractiles: ______0.80____0.85____0.90___ 0.95____0.99__
__n=5 _____0.2163__0.2246__0.2351__0.2498__0.2767__2nd _____0.2895__0.3028__0.3190__0.3431__0.3964__1st _____0.2893__0.3027__0.3188__0.3427__0.3959__M.A.
__n=10 _____0.1761__0.1843__0.1950__0.2123__0.2475__ _____0.2171__0.2273__0.2410__0.2622__0.3035__ _____0.2171__0.2273__0.2410__0.2616__0.3037__
__n=15 _____0.1534__0.1609__0.1709__0.1866__0.2191__ _____0.1845__0.1899__0.2014__0.2192__0.2542__ _____0.1811__0.1899__0.2016__0.2196__0.2245__
__n=20 _____0.1379__0.1448__0.1538__0.1682__0.1975__ _____0.1588__0.1664__0.1763__0.1918__0.2236__ _____0.1589__0.1666__0.1764__0.1920__0.2226__
__n=25 _____0.1263__0.1327__0.1411__0.1543__0.1815__ _____0.1430__0.1498__0.1589__0.1731__0.2015__ _____0.1429__0.1498__0.1589__0.1726__0.2010__
__n=30 _____0.1174__0.1233__0.1311__0.1434__0.1686__ _____0.1313__0.1376__0.1458__0.1588__0.1849__ _____0.1315__0.1378__0.1460__0.1590__0.1848__
__n=35 _____0.1101__0.1157__0.1230__0.1346__0.1582__ _____0.1220__0.1279__0.1356__0.1475__0.1719__ _____0.1220__0.1278__0.1356__0.1478__0.1720__
__n=40 _____0.1041__0.1094__0.1163__0.1272__0.1495__ _____0.1144__0.1200__0.1272__0.1384__0.1614__ _____0.1147__0.1204__0.1275__0.1386__0.1616__
__n=45 _____0.0991__0.1041__0.1107__0.1211__0.1422__ _____0.1082__0.1135__0.1203__0.1310__0.1527__ _____0.1083__0.1134__0.1204__0.1309__0.1525__
__n=50 _____0.0946__0.0994__0.1057__0.1155__0.1355__ _____0.1028__0.1078__0.1143__0.1244__0.1448__ _____0.1030__0.1079__0.1142__0.1246__0.1457__
Explanation
The third lines (M.A.) show the Morin/Abdil values, the remaining two, mine: the first records the sub maxima, the second the KSLilliefors maxima. It can be seen easily that there is an excellent agreement between lines which demonstrate that my simulations got correct values. It should be stresses that I simulate 1 million samples by sample size and them 100 000. It?s true that the fourth decimal places are absolutely abusive in view the forecasted random errors. We intend to explore a little how informative (if so) is this *second* maximum in view the conclusions to draw from tests. The program ?New? listing follows.
Luis A. Afonso
REM "NEW" CLS PRINT : PRINT COLOR 12 PRINT " 1st maximum and 2nd KOLMOGOROV  SMIRNOV "; PRINT "LILLIEFORS test statistics " INPUT " n (SAMPLE SIZE) = "; n INPUT " HOW MANY SAMPLES = "; ali pi = 4 * ATN(1): c = 1 / SQR(2 * pi) DIM x(n), xx(n), F(n), y(n) DIM max(9001), max2(9001) DEF fng (z, j) = .5 * z ^ 2 * (2 * j + 1) / ((j + 1) * (2 * j + 3)) F(0) = 0 FOR ji = 0 TO n: F(ji) = ji / n: NEXT ji REM REM REM k = SAMPLE FOR k = 1 TO ali: RANDOMIZE TIMER mmajor = 1E20: second = mmajor LOCATE 7, 50: PRINT USING "##########"; ali  k md = 0: sum2 = 0 REM FOR i = 1 TO n a = SQR(2 * LOG(RND)) x(i) = a * COS(2 * pi * RND) md = md + x(i) / n sum2 = sum2 + x(i) * x(i) NEXT i sqd = sum2  n * (md ^ 2): sd = SQR(sqd / (n  1)) FOR ii = 1 TO n: x(ii) = (x(ii)  md) / sd: NEXT ii REM ORDERING FOR ii = 1 TO n: u = x(ii): W = 1 FOR jj = 1 TO n IF x(jj) < u THEN W = W + 1 NEXT jj: xx(W) = u NEXT ii REM "******************" REM PHI CALCULATION FOR tt = 1 TO n: z = xx(tt) IF z >= 0 THEN kw = 0 IF z < 0 THEN kw = 1 zu = ABS(z): s = c * zu: antes = c * zu FOR j = 0 TO 100000 xx = antes * fng(zu, j) s = s + xx antes = xx IF ABS(xx) < .00004 THEN GOTO 20 NEXT j 20 IF kw = 0 THEN FF = .5 + s IF kw = 1 THEN FF = .5  s b = ABS(FF  F(tt  1)) bb = ABS(F(tt)  FF) maior = b IF bb > b THEN maior = bb x(tt) = maior GOTO 99 REM local difference= x(tt) 99 REM NEXT tt higher = 1 FOR ii = 1 TO n IF x(ii) <= higher THEN GOTO 22 higher = x(ii): llocal = ii 22 NEXT ii LOCATE 10, 1 x(llocal) = 2: high = 1 FOR i2 = 1 TO n IF x(i2) <= high THEN GOTO 33 high = x(i2): ll = i2 33 NEXT i2 higher = INT(10000 * higher + .5) IF higher > 8000 THEN higher = 8000 high = INT(10000 * high + .5) IF high > 9000 THEN high = 9000 max(higher) = max(higher) + 1 / ali max2(high) = max2(high) + 1 / ali NEXT k COLOR 14 LOCATE 8, 10 PRINT " largest 2nd " c(0) = .8: c(1) = .85: c(2) = .9 c(3) = .95: c(4) = .99 FOR tu = 0 TO 4: smax = 0 FOR zx = 0 TO 8000 smax = smax + max(zx) IF smax > c(tu) THEN GOTO 4 NEXT zx 4 LOCATE 10 + tu, 15 PRINT USING "#.#### "; zx / 10000; smax NEXT tu: smax = 0 FOR tu = 0 TO 4: smax = 0 FOR zx = 0 TO 8000 smax = smax + max2(zx) IF smax > c(tu) THEN GOTO 5 NEXT zx 5 LOCATE 10 + tu, 45 PRINT USING "#.#### "; zx / 10000; smax NEXT tu COLOR 7 END



