proc iml;
call randseed(4545); * initialize the stream (like streaminit);
x = J(5000,1,.); * pre-allocate space for random numbers;
call randgen(x,'normal',0,1); * fill x with N(0,1) deviates;
y = y + (x**2 - 3*x**3 + 5x < 1);
p = y / 5000; * MEAN acts on each matrix column;
se = sqrt(y*(1-y)/5000); * VAR, but not STD or STDERR, also acts on columns;
print "IML STEP: estimated probability is" p
"with standard error" se; * use PRINT, not PUT;
我正在尝试使用蒙特卡罗集成与 proc iml 来估计 x**2 - 3*x**3 + 5x 小于 1 的概率。我做错了什么?顺便说一句,Do 循环是不允许的。