A routine for the Normal Distribution
The inputs are:
Left limit, Right limit
The output
The integral between the limit of N(0.1) – Normal standard.
If limit= -infinity input -7
If limit= +infinity input 7
The results have 7 decimals exact.
______licas (Luis A. Afonso)
REM "zazeu"
DEFDBL A-Z
17 CLS
DEFDBL A-Z
PRINT "***** NORMAL LAW *****"
PRINT " INTEGRAL between : left and right limits "
PRINT " (one of them or both could be negative "
PRINT " NO one lesser than -7 or greater than 7) "
INPUT " left "; za
INPUT " right "; zu
IF za >= zu THEN GOTO 17
pi = 4 * ATN(1): c = 1 / SQR(2 * pi)
amb = 1
IF za >= 0 AND zu >= 0
OR za <= 0 AND zu <= 0 THEN amb = 2
DEF fng (x, j) =
-x ^ 2 * (2 * j + 1) / ((j + 1) * (2 * j + 3)) * .5
FOR ft = 1 TO 2
x = ABS(zu): s(ft) = 0
IF ft = 1 THEN x = ABS(za)
s(ft) = c * x: ant = c * x
FOR j = 0 TO 1000
xx = ant * fng(x, j)
s(ft) = s(ft) + xx
ant = xx
IF ABS(ant) < 1E-09 THEN GOTO 100
NEXT j
100 PRINT
NEXT ft
IF za >= 0 AND zu >= 0 THEN GOTO 1
IF za <= 0 AND zu >= 0 THEN GOTO 2
IF za <= 0 AND zu <= 0 THEN GOTO 3
1 PRINT " ";
PRINT USING "#.#######";
s(2) - s(1): GOTO 222
2 PRINT " ";
PRINT USING "#.#######";
s(2) + s(1): GOTO 222
3 PRINT " ";
PRINT USING "#.#######";
s(1) - s(2)
222 PRINT " MORE DATA ? "
PRINT " if YES --> key ENTER "
PRINT " if NOT --> any key "
INPUT a$
IF a$ = "" THEN GOTO 17
CLS : END
.