Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.


Luis A. Afonso
Posts:
4,661
From:
LIsbon (Portugal)
Registered:
2/16/05


A homemade routine for the Normal Cumulative Distribution
Posted:
Sep 24, 2012 7:37 PM


A homemade routine for the Normal Cumulative Distribution
If x is a Normal standard r.v. it can be found that the respective cumulative value (the integral from ?infinity to x of the density) could be expressed by the power series :
F(x)= 0.5 + !/sqrt(2*pi) * sum a_n n=1,2, ? , infinity
_a_n = [(1)^n * x ^(2*n+1)]/[n! * 2^n * (2*n + 1)]
(Abromowitz , Stegun, Handbook of Mathematical Functions, 26.2.10)
We easily got
___u_(n+1) / u_n = 0.5* x^2 *[(2*n + 1) / ((n+1)* (2*n+3))]
This recurrence formula with a_0 = x^2 allows us to calculate F(x) with negligible calculus error. The program below can reach for example
_____F(5) = 0.99999´97133´48158 _____F(4) = 0.99996´83287´58163 _____F(3) = 0.99865´01019´68370 _____F(2) = 0.97724´98680´51821 _____F(1) = 0.84134´47460´68543 _____F(0) = 0.50000´00000´00000 _____F(1) = 0.15865´52539´31457 _____F(2) = 0.02275´01319´48179 _____F(3) = 0.00134´98980´31630 _____F(4) = 0.00003´16712´41837 _____F(5) = 0.00000´02866´51842
,which are the same as presented in Bibliography.
Luis A. Afonso
REM "NORMAL" CLS PRINT " NORMAL: z > F(z) "; PRINT " AGAIN > ENTER " DEFDBL AZ 11 INPUT " Z="; z XC = XC + 2 pi = 4 * ATN(1): c = 1 / SQR(2 * pi) DEF fng (z, j)= .5 * z ^ 2 * (2 * j + 1) / ((j + 1) * (2 * j + 3)) REM REM calculating Fi(z) IF z > 0 THEN kw = 0 IF z <= 0 THEN kw = 1 zu = ABS(z): s = c * zu: antes = c * zu FOR j = 0 TO 10000 xx = antes * fng(zu, j) antes = xx s = s + xx IF ABS(xx) < .5 * e  17 THEN GOTO 20 NEXT j 20 IF kw = 0 THEN ff = .5 + s: IF kw = 1 THEN ff = .5  s LOCATE XC, 25 PRINT " Fi("; z; ")= "; PRINT USING "##.############### "; ff PRINT " again > enter " INPUT a$ IF a$ = "" THEN GOTO 12 END 12 LOCATE 2 + XC, 1: PRINT " " GOTO 11 END



