Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » sci.math.* » sci.stat.math.independent

Topic: A home-made routine for the Normal Cumulative Distribution
Replies: 0  

Advanced Search

Back to Topic List Back to Topic List  
Luis A. Afonso

Posts: 4,526
From: LIsbon (Portugal)
Registered: 2/16/05
A home-made routine for the Normal Cumulative Distribution
Posted: Sep 24, 2012 7:37 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

A home-made 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 A-Z
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



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.