We intent this time to show how the P-values are distributed when one tests the difference of mean normal Populations. To this purpose samples X~N (0, 1).n and Y~N (0, 1): n are simulated and the statistics is: T = (xhat ? yhat - D)/s __s^2 = (ssdX + ssdY)/(n+n-2) * (1/nX + 1/nY) It´s known that T follows a Student T with nX + nY - 2 df. Lacking an algorithm to provide the inverse T we switched to normal which is sufficiently accurate since the sample sizes are large, n=100, because student t with 100+100-2= 198 df is very lose to normal standard. See 26.2.10 M. Abramowitz, I. Stegun, Handbook of Mathematical Functions. A recurrence formula (program WATCH) my own, was used.
Results and Discussion
P-values are shown (not in full) distributed in classes each one 0.05 amplitude. One get only 2% *rejections* from [0, 1], and any (as expected) when D= 0. We counted 1- alpha(D= -0.5) = 37982/40000 = 0.950, 1- alpha(D= 0.5) = 37903/40000 = 0.948 very close to 0.95, as it was demanded.
REM "WATCH" CLS DEFDBL A-Z PRINT : PRINT : PRINT "___WATCH____" INPUT " Two N(0,1) samples , size "; size INPUT " D= "; mu INPUT " How many "; repeat pi = 4 * ATN(1): cx = 1 / SQR(2 * pi) DIM kk(20) DEF fng (x, k) = -.5 * x ^ 2 * (2 * k + 1) / ((k + 1) * (2 * k + 3)) FOR j = 1 TO repeat: RANDOMIZE TIMER LOCATE 5, 50 PRINT USING "#########"; repeat - j PRINT : PRINT m1 = 0: m2 = 0: ss1 = 0: ss2 = 0 FOR i = 1 TO size: r1 = RND: r2 = RND aa = SQR(-2 * LOG(r1)) x = aa * COS(2 * pi * r2) y = aa * SIN(2 * pi * r2) m1 = m1 + x / size: ss1 = ss1 + x * x m2 = m2 + y / size: ss2 = ss2 + y * y NEXT i ssd1 = ss1 - size * m1 * m1 ssd2 = ss2 - size * m2 * m2 sz = 1 / size + 1 / size t = (m1 - m2) / SQR((ssd1 + ssd2) / (size + size - 2) * sz) x = t REM x = (m1 - m2 - mu) / SQR(2 / size) REM ___ x^-1___ zu = ABS(x): s = cx * zu: ante = cx * zu FOR k = 0 TO 7777777 xx = ante * fng(zu, k) s = s + xx IF ABS(xx) < .0000005 THEN GOTO 10 ante = xx NEXT k 10 REM IF x < 0 THEN np = .5 - s IF x >= 0 THEN np = .5 + s IF np < 0 THEN lft = lft + 1 IF np > 1 THEN rgt = rgt + 1 REM by classes FOR c = 0 TO 19 t0 = c / 20: t1 = (c + 1) / 20 IF np > t0 AND np < t1 THEN kk(c) = kk(c) + 1 NEXT c PRINT "______________wait please " NEXT j FOR y = 0 TO 19: sum = sum + kk(y) PRINT USING " ###) ###### "; y; kk(y); NEXT y PRINT sum PRINT USING " ###### "; lft; rgt END