Re: Monte Carlo: random simulation of events
- From: "\"Luis A. Afonso\"" <licas_@xxxxxxxxxxx>
- Date: Sun, 10 Sep 2006 11:28:21 EDT
MC-3 Testing differences on PROPORTIONS
__EXEMPLE #3
Suppose I want to test
_____H0: p1<=p2_____H1: p1>p2
when I draw a random sample (n1=50) with p1=0.5 from the Population 1 and another sample (n2=50), p2=0.1 from the Population 2.
The ABSOLUTE EXACT TEST is the following
___p(H0 true) = p(x<=y*n1/n2)
which is the sum of p(x)*p(y), from y=0 to y=n2, for all x such that x>=INT(y*n1/n2).
Result:
____p(H0 not rejected) = 0.9784642773435
No pooled variance
Only as comparison test Z gave Z0=1.92897 and with the Normal Approximation p(Z<Z0) = 0.973132706669889.
______licas (Luis A. Afonso)
REM "FORx"
CLS
DEFDBL A-Z
PRINT " p(x<=y*n1/n2) "
INPUT " n1 , p1 "; n1, p1
INPUT " n2 , p2 "; n2, p2
DIM px(n1), py(n2)
px(0) = (1 - p1) ^ n1
FOR j = 0 TO n1 - 1
px(j + 1) = px(j) * (n1 - j) / (j + 1) * p1 / (1 - p1)
NEXT j
py(0) = (1 - p2) ^ n2
FOR j = 0 TO n2 - 1
py(j + 1) = py(j) * (n2 - j) / (j + 1) * p2 / (1 - p2)
NEXT j
FOR yy = 0 TO n2
c = INT(n1 / n2 * yy)
FOR xx = c TO n1 : s = s + px(xx) * py(yy)
22 NEXT xx
PRINT USING " ### ### #.### "; yy; c; s;
NEXT yy
PRINT s
v = p1 * (1 - p1) / n1 + p2 * (1 - p2) / n2
s = SQR(v) : z = (p1 - p2) / s
PRINT z : END
.
- Follow-Ups:
- Re: Monte Carlo: random simulation of events
- From: Jack Tomsky
- Luis A. Afonso SELF-IMMOLATES for the FIFTH time
- From: Reef Fish
- Re: Monte Carlo: random simulation of events
- References:
- Monte Carlo: random simulation of events
- From: \"Luis A. Afonso\"
- Monte Carlo: random simulation of events
- Prev by Date: The Chronicles of Bob Ling's bumbLINGs
- Next by Date: POD (PCA) analysis, monte carlo simulation, variance reduction
- Previous by thread: Re: Monte Carlo: random simulation of events
- Next by thread: Luis A. Afonso SELF-IMMOLATES for the FIFTH time
- Index(es):
Relevant Pages
|