gzjb 发表于 2010-11-3 10:43 
saiyasaibing 发表于 2010-11-3 03:12 
如何用sas来计算双重积分呢?
我有看过sas document, 用iml quad call来做积分。
可是,我计算的情况是,dxdy, 内部积分的上限里有y。
实在是不知道怎么处理了...
高手帮帮忙。
It's extremely easy.
MC-method
step1 determine a rectangle or square which bounds the integral region
step2. Generate the random number pairs (points in 2D)
step3. Calculate the probability P of points located in the integral region
step4. integral=P*area of rectangle or square
For 3 dimension to n>3 dimension , same idea.
MCMC works very well. Easy to program in SAS or other language . I did integral from 1D to 3D many years ago.
I will send you programs if I have time and can find it.
MC method is the last solution if there is no way to integral. I am not sure how SAS calculates the integral. It certianly is a lot of faster than MC.
Here is an example of integal of 4xy on x=[0,1] and y=[0,x];
****integal of 4xy on x=[0,1] and y=[0,x];
proc iml;
start integal_Y (y) global(a);
return(4#a#y);
finish;
start integal_X (x) global(a);
a = x;
RY = 0 || a;
call quad(w, "integal_Y", RY);
return (w);
finish;
RX= {0 1};
call quad(v, "integal_X", RX);
print v;
RX= {0 2};
call quad(v, "integal_X", RX);
print v;
RX= {0 4};
call quad(v, "integal_X", RX);
print v;
quit;