'**************************************************** '* Program to demonstrate inverse normal subroutine * '* ------------------------------------------------ * '* Reference: BASIC Scientific Subroutines, Vol. II * '* By F.R. Ruckdeschel, BYTE/McGRAWW-HILL, 1981 [1].* '* ------------------------------------------------ * '* SAMPLE RUN: * '* * '* P(Z>X) X * '* ---------------- * '* 0.50 0.0000 * '* 0.48 0.0500 * '* 0.46 0.1002 * '* 0.44 0.1507 * '* 0.42 0.2015 * '* 0.40 0.2529 * '* 0.38 0.3050 * '* 0.36 0.3580 * '* 0.34 0.4120 * '* 0.32 0.4673 * '* 0.30 0.5240 * '* 0.28 0.5825 * '* 0.26 0.6430 * '* 0.24 0.7060 * '* 0.22 0.7719 * '* ? * '* 0.20 0.8414 * '* 0.18 0.9152 * '* 0.16 0.9944 * '* 0.14 1.0804 * '* 0.12 1.1751 * '* 0.10 1.2817 * '* 0.08 1.4053 * '* 0.06 1.5551 * '* 0.04 1.7511 * '* 0.02 2.0542 * '* * '**************************************************** DEFINT I-N DEFDBL A-H, O-Z CLS PRINT PRINT " P(Z>X) X " PRINT "----------------" i = 1 FOR y = .5 TO 0 STEP -.02 GOSUB 1000 IF x < .000001 THEN x = 0 PRINT USING " #.## #.####"; y; x IF i = 15 THEN INPUT r\$: i = 1 END IF i = i + 1 NEXT y PRINT END '*********************************************** '* Inverse normal distribution subroutine * '* ------------------------------------------- * '* This program calculates an approximation to * '* the integral of the normal distribution * '* function from x to infinity (the tail). * '* A rational polynomial is used. The input is * '* in y, with the result returned in x. The * '* accuracy is better then 0.0005 in the range * '* 0 < y < 0.5. * '* ------------------------------------------- * '* Reference: Abramowitz and Stegun. * '*********************************************** 1000 'Define coefficients c0 = 2.515517# c1 = .802853# c2 = .010328# d1 = 1.432788# d2 = .189269# d3 = .001308# IF y = 0 THEN x = 1E+13# IF y = 0 THEN RETURN z = SQR(-LOG(y * y)) x = 1# + d1 * z + d2 * z * z + d3 * z * z * z x = (c0 + c1 * z + c2 * z * z) / x x = z - x RETURN 'End of file invnorm.bas