
Chapter 11: Programming with Matrices and Vectors 403
J(nsim,2,0), initializes the matrix temp_mat to have nsim rows, and for two
columns to have all zeros.
Display 11.9 Using SAS/IML to estimate π using Monte Carlo integration (pts. in first
quadrant)
proc iml;
nsim = 4000;
temp_mat = J(nsim,2,0);
/* Generate (X,Y) with single call using 'randgen' */
call randseed(21509); * set seed for randgen;
call randgen(temp_mat,'uniform');
temp_mat = temp_mat || (temp_mat[,2]<= sqrt(J(nsim,1,1)-
temp_mat[,1]##2));
pi_over4 = temp_mat[+,3]/nsim;
pi_est = 4*pi_over4;
se_est = 4*sqrt(pi_over4*(1-pi_over4)/nsim);
pi_LCL = pi_est - 2*se ...