Standard Normal Distribution Script
Webb - all rights reserved - ©2004
spacer
Author - Russ Lenth
Email: russell-lenth@stat.uiowa.edu
Webpage:

Summary: pdf, cdf, and quantile of the N(0,1) distribution.

Instructions: This adds basic functionality for the normal distribution.

The pdf at z is the function phi(z) = exp(-.5 z^2) / sqrt(2pi).

The cdf is the function Phi(z) = integral phi(t)dt from t = -infinity to t = z.

The quantile is the solution z to the equation Phi(z) = p where p is the value supplied.

The algorithm for the cdf is (26.2.16) in Abramowitz and Stegun, which is accurate to +/- 1e-5. (It'd be easy but bulkier to use (26.2.17), accurate to +/ -1e-8).

The quantile is obtained using the Tukey's lambda approximation z = 4.92{p^.14 - (1-p)^.14} as a starter, and doing one Newton step.


Code:

RPN.1
[d]g1*Hne#'.39894228'*;
[p]g10<(nCpn1+:g1#'.33267'*1+tg1g1#'.9372980'*#'.1201676'-*#'.4361836'+*r2Cd*n1+);

[q]g1g1#'.14'Pr2n1+#'.14'P-#'4.92'*r2g2Cp-g2Cd/+;
"Normal dist"
"_p(x): pdf"Cd;
"_P(x): cdf"Cp;
"_Q(x): quantile"Cq;