Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Topic: Kolmogorov-Smirnov-Lilliefors Test statistics
Replies: 10   Last Post: Jun 8, 2013 7:39 PM

 Messages: [ Previous | Next ]
 Luis A. Afonso Posts: 4,758 From: LIsbon (Portugal) Registered: 2/16/05
Re: Kolmogorov-Smirnov-Lilliefors Test statistics
Posted: Jun 5, 2013 10:49 AM

The main goal: To decide if a sample items (n=100) could be considered or not i.i.d from a Normal Population using the two versions, Dmax, D2max, of the Kolmogorov-Smirnov-Lilliefors test. The sample was found in a Elementary Statistical Textbook (Hogg, Tanis, Probability and Statistical Inference, 4th edition, pg. 233-234).
The routine <NEWDATA> below calculates the values
Dmax=0.12735, D2max=0.12157
For N(mean=456.2, sd=2.441) estimated from data.
Note that to not have ties to each one item was added the quantity g= (0.5 - rnd)/100000, then warranting -0.000005< g <0.000005, then both D´s reproducible at 5 decimal places.
Conclusions:
For Dmax critical values, 5%= 0.0888, 1% =0.1034 we can be sure that data doesn´t follow a Normal Distribution.
The same conclusion is got through D2max : critical values 0.0847, 0.0991 respectively.

Luis A. Afonso

REM "NEWDATA"
CLS
DEFDBL A-Z
RANDOMIZE TIMER
PRINT : PRINT
PRINT "__________________________ NEWDATA "
n = 100
DIM x(n), xx(n), diff(n), F(n)
DEF fng (z, j) = -.5 * z * z * (2 * j + 1) / ((j + 1) * (2 * j + 3))
pi = 4 * ATN(1): c = 1 / SQR(2 * pi)
FOR h = 1 TO n: F(h) = h / n: NEXT h
REM
REM
DATA 457,457,455,457,454,454,457,455,456,459
DATA 457,458,456,456,461,457,458,452,457,460
DATA 453,458,452,454,454,456,455,456,451,454
DATA 456,457,457,453,455,459,458,457,458,457
DATA 461,457,455,458,458,455,457,458,456,463
DATA 455,455,455,456,456,456,455,456,460,456
DATA 456,457,458,454,455,456,459,457,457,451
DATA 450,453,453,459,450,453,452,458,456,457
DATA 451,458,456,460,455,455,456,460,457,456
DATA 457,456,460,459,457,455,461,455,457,457
mean = 0: ss = 0
FOR i = 1 TO n: READ x(i)
x(i) = x(i) + (.5 - RND) / 100000
mean = mean + x(i) / 100
ss = ss + x(i) * x(i)
NEXT i
ssd = ss - n * mean * mean
var = ssd / 99: sd = SQR(var)
PRINT : PRINT : PRINT : PRINT : PRINT
PRINT " ";
PRINT " mean, sdev. ";
PRINT USING "###.### "; mean; sd
FOR i = 1 TO n: x(i) = (x(i) - mean) / sd
xx(i) = x(i): NEXT i
PRINT
REM
mmajor = -1E+20: second = -1E+20
REM
md = 0: soma2 = 0
REM
REM ordered values: xx( )
REM
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 "*********************"
REM phi calculation

FOR tt = 1 TO n: z = xx(tt)
zu = ABS(z): s = c * zu: ante = c * zu
FOR j = 0 TO 4444444
xx = ante * fng(zu, j)
s = s + xx
ante = xx
IF ABS(xx) < .00000049# THEN GOTO 20
NEXT j
20 IF z >= 0 THEN FF = .5 + s
IF z < 0 THEN FF = .5 - s
b = ABS(FF - F(tt - 1))
bb = ABS(F(tt) - FF): REM F(tt=0)=0
major = b
IF bb > b THEN major = bb
diff(tt) = major
NEXT tt
REM local difference = diff(tt)
higher = -1
FOR ii = 1 TO n
IF diff(ii) <= higher THEN GOTO 22
higher = diff(ii): llocal = ii
22 NEXT ii
REM
REM
diff(llocal) = -2: high = -1
FOR i2 = 1 TO n
IF diff(i2) <= high THEN GOTO 33
high = diff(i2): i1 = i2
33 NEXT i2
LOCATE 14, 30
COLOR 14
PRINT " Dmax, D2max ";
PRINT USING " #.##### "; higher; high
END

Date Subject Author
9/16/12 Luis A. Afonso
9/18/12 Luis A. Afonso
9/20/12 Luis A. Afonso
9/20/12 Luis A. Afonso
9/22/12 Luis A. Afonso
9/22/12 Luis A. Afonso
6/4/13 Luis A. Afonso
6/5/13 Luis A. Afonso
6/5/13 Luis A. Afonso
6/7/13 Luis A. Afonso
6/8/13 Luis A. Afonso