Search All of the Math Forum:

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

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

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 8:00 PM

p-values of DATA (if normal)

____Simulating size=100, 40000 normal samples, mu=456.2, sigma=2.441 we record how much of them provide Dmax greater than the observed Dmax= 0.12735 and D2max= 0.12157. This is the obvious way to get the respective p-values of DATA for 5% significance. We know yet that the relative frequencies are very lower than 0.05. Otherwise it was inconsistent with results of the respective test critical values (0.0888, 0.0847).
Results, p-values , 5% significance level (routine <PONG>)
___________________Dmax ____D2max
_______1st attempt __ 0.0005 ____0.0005___
_______2nd_________0.0005 ____0.0006___
_______3rd_________ 0.0005 ____0.0005___
_______4th_________ 0.0006 ____0.0006___

As expected, the sample under study is very (very) unlike to have been drawn from a normal population.

Luis A. Afonso
REM "PONG"
CLS
DEFDBL A-Z
RANDOMIZE TIMER
PRINT : PRINT
PRINT "__________________________ PONG "
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
mu = 456.2: sigma = 2.441
REM
ally = 40000
REM
FOR ju = 1 TO ally
LOCATE 3, 50: PRINT USING "#########"; ally - ju
meanX = 0: ssX = 0
high = 0: higher = 0
FOR i = 1 TO 100
aa = SQR(-2 * LOG(RND))
X(i) = mu + sigma * aa * COS(2 * pi * RND)
meanX = meanX + X(i) / n
ssX = ssX + X(i) * X(i)
NEXT i
ssdX = ssX - n * meanX * meanX
varX = ssdX / (n - 1)
mean = meanX
sd = SQR(varX)
REM
REM
FOR i = 1 TO n: X(i) = (X(i) - mean) / sd
xx(i) = X(i): NEXT i
REM 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
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
REM
REM
REM 5% significance level
REM
IF higher > dataDmax THEN f1 = f1 + 1 / ally
IF high > dataD2max THEN f2 = f2 + 1 / ally
NEXT ju
PRINT
PRINT " __________5% Dmax__________"
PRINT USING " ##.#### "; f1
PRINT " __________5% D2max_________"
PRINT USING " ##.#### "; f2
REM
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