
Re: Binomial law DF: a simple program
Posted:
Jun 13, 2007 12:11 AM


> Binomial law DF: a simple program > > N=110, p=0.2 > > ________p(X<=110) = 1.0000000000 > ________p(X<=10) = 0.0015595228 > ________p(X<=22) = 0.5567271744 > ________p(X<=30) = 0.9752864841 > ________p(X<=50) = 0.9999999996 > ________ > ________Licas > > > REM "BINcum" > CLS > DEFDBL AZ > PRINT " F(a) = p(X<=a) X=Bin(p, N) " > INPUT " p , N "; p, n > INPUT " a ( a<=n ) "; a > w = p / (1  p) > DIM pp(n) > pp(0) = (1  p) ^ n: s = pp(0) > IF a = 0 THEN GOTO 10 > FOR j = 0 TO n  1 > IF j > a  1 THEN GOTO 10 > pp(j + 1) = pp(j) * (n  j) / (j + 1) * w > s = s + pp(j + 1) > NEXT j > 10 LOCATE 10, 50: PRINT USING "#.########## "; > s > END
Now for the same cases, compare these simple exact results with the Afonso normal approximation employing his continuity correction.
p(X<=110)= 1.0000000000 p(X<=10) = 0.0030607156 p(X<=22) = 0.5474347428 p(X<=30) = 0.9786231409 p(X<=50) = 1.0000000000
The conclusion is that it is better to use the simple exact binomial calculations.
Jack

