讲稿解答_采油答疑讲稿
讲稿解答由刀豆文库小编整理,希望给你工作、学习、生活带来方便,猜你可能喜欢“采油答疑讲稿”。
2012讲稿解答程序如下
n=5000;%simulation number
f=0;% initial frequency
for i=1:n
t1=unifrnd(1,3);% time of the first man coming
t2=normrnd(2,1);% time of the second man coming
while t23%t2 does not satisfy the requirement of the subject
t2=normrnd(2,1);%t2 is generated again
end
if abs(t1-t2)
f=f+1;
end
end
f=f/n% derive the frequency
结果自己运行将lamda=4;改为lamda=10;将singlesurcetime=exprnd(mu)的等式右端分别改为normrnd(9,2)和9即可,结果自己运行。
3积分计算式子应该是
syms x y
z=exp(-(x^2+y^2));
a=4*int(int(z,y,0,2*sqrt(9-x^2)/3),x,0,3)
但结果看不懂,是用一些特殊函数表示。
用蒙特卡罗模拟程序为
n=3000;% simulation number
N=0;%useful simulation number
I=0;% initial number
for i=1:n
x=unifrnd(-3,3);% random number satisfying U(-3,3)
y=unifrnd(-2,2);% random number satisfying U(-2,2)
if 4*x^2+9*y^2
N=N+1;% only in this case N needs to be added
I=I+exp(-(x^2+y^2));% add sample value
end
end
I=pi*3*2*I/N% derive approximate value
注意: 设φ(x,y)是在椭圆4x2+9y2=36内服从均匀分布的密度函数,则φ(x,y)=1/6π,记f(x,y)=exp(-(x2-y2)),于是Df(x,y)dxdy11f(xi,yi),据此不难理解上f(x,y)(x,y)dxdy(x,y)D(x,y)N
面程序(相对于ppt中的程序,把φ(x,y)=1/6π放在后面去乘)。其实,程序思路很简单,想想积分中值定理,在椭圆内取许多点求出这些点函数值的平均值,再乘积分面积就该是整个的积分。