options crt ; name bivar 'Example of Approximating a Bivariate Normal Distribution' ; ? ? TSP 4.2A (Sept 1992) ? Author: Clint Cummins ? SMPL 1,100; ? ? This equation approximates a standard bivariate normal ? distribution with zero means and correlation coefficient rho. ? It's from Abramovitz and Stegun, Handbook of Mathematical Functions, ? formula 26.3.29. ? frml biv pr = cnorm(XB1)*cnorm(XB2) + norm(XB1)*norm(XB2)*( rho + rho**2*XB1*XB2/2 + rho**3*(XB1**2 - 1)*(XB2**2 - 1)/6 ); READ(NROW=2,TYPE=SYM) COV; 1 .1 1 ; DO RHO = .1 TO .91 BY .1; SET COV(2,1) = RHO; RANDOM(VCOV=COV) XB1 XB2; GENR BIV; PRINT RHO; ? ? CDF computes the "true" bivariate normal distribution. ? CDF(BIVNORM,RHO=RHO) XB1 XB2 TRUE; ? ? Compute the approximation error and print statistics on it. ? APPERR = TRUE - PR; MSD APPERR; ENDDO; stop ; end ;