The difference of two normal means
- From: "\"Luis A. Afonso\"" <licas_@xxxxxxxxxxx>
- Date: Wed, 23 Nov 2005 15:03:23 EST
Monte Carlo method has certainly better utility than this one:; however it can illustrate some theoretical results which is a no negligible pedagogical feature. The procedure in what concerns Hypothesis Testing follows generally the steps:
__1_sample synthesizing (randomly),
__2_evaluatin of the sample(s) statistics related to H0,
__3_through a enormous amount of data obtained as above to find the statistics critical values.
The case is the difference of two normal means,
X=N(meanX, std.dev.X): sizeX
Y=N(meanY, std.dev.Y):sizeY
I put :
Case 1 : X=N(100,10):10 and Y(90,10):10
Critical Values of the difference
_______z = ((xhat-yhat)- 10)/sqr(100/10+100/10)
____freq.(z>1.961) = 0.950
____freq.(z>1.964) = 0.950
***
Case 2 : X=N(100,10):10 and Y(80,10):10
Critical Values of the difference
_______z = ((xhat-yhat)- 20)/sqr(100/10+100/10)
____freq.(z>1.960) = 0.950
____freq.(z>1.962) = 0.950
***
These limits must be compared with the theoretical one: 1.960. the differences have a maximum 0.004/1.960 = 0.002. The expected relative error should be 1/ sqr (100000) = 0.003 which is a estimate of the critical values relative errors; all the 4 observed differences (2 runs for each case) are lesser.
REM "WRONG"
CLS
DIM has(9000)
RANDOMIZE TIMER
pi = 4 * ATN(1)
INPUT " nx, ny "; n1, n2
INPUT " Means "; m1, m2
s1 = 10: s2 = 10
nn = SQR(s1 * s1 / n1 + s2 * s2 / n2)
all = 100000
FOR v = 1 TO all
mx = 0: my = 0
FOR i = 1 TO n1: a = SQR(-2 * LOG(RND)): r = RND
x = m1 + s1 * a * COS(2 * pi * r): z = (x - 100) / s1
mx = mx + x / n1
NEXT i
FOR j = 1 TO n1: a = SQR(-2 * LOG(RND)): r = RND
y = m2 + s2 * a * SIN(2 * pi * r)
my = my + y / n2: z = (y - ABS(m1 - m2)) / s2
NEXT j
LOCATE 10, 10: PRINT USING "#########"; all - v
w = (mx - my - INT(m1 - m2)) / nn
w = INT(1000 * w + .5): w = w + 3000
IF w < 0 THEN w = 0
IF w > 9000 THEN w = 9000
REM PRINT USING "###### "; w;
has(w) = has(w) + 1
RANDOMIZE TIMER
20 NEXT v
lmt = .975 * all
FOR k = 0 TO 9000
s = s + has(k)
IF s > lmt THEN GOTO 33
NEXT k
33 PRINT USING "##.### #.### "; (k - 3000) / 1000; s / all
END
____________licas (Luis A. Afonso)
.
- Prev by Date: Re: Effect of parametrization in regularized regression
- Next by Date: Re: Questions on the F-Test *VS* the Chi-Square Test
- Previous by thread: StatXact bug
- Next by thread: wald's sequential test
- Index(es):