可编辑修改
1. Using Monte Carlo simulation, write a Matlab program to calculate an
approximation to by considering the number of random points lected
inside the quarter circle
Q:xy1,x0,y0
22
where the quarter circle is taken to be inside the square
S:0x1,0y1
解:
counter=0;
N=100000;
for i=1:N
x=rand(1,1);
y=rand(1,1);
if x^2+y^2<1
counter=counter+1;
简介英语 end
end
p=4*counter/N
结果:p = 3.1448
2. Using Monte Carlo simulation, write a Matlab program to calculate
the volume of an ellipsoid(椭球体)
xyz
222
16
248
解:
counter=0;
N=1000;
for i=0:N
x=-4*sqrt(2)+8*sqrt(2)*rand(1,1);
y=-8+16*rand(1,1);
z=清彻 -8*sqrt(2)+16*sqrt(2)*rand(1,1);
if x^2/2+y^2/4+z^2/8<16
counter=counter+1;
end
end
v=counter/N*8*sqrt(2)*16*16*sqrt(2)
结果:v = 2.2528e+003
3. U Monte Carlo simulation to simulate the roll粽子的寓意 s of an unfair
die. Assume the die is biad according to the following
empirical distribution:
Roll Probabil
Value i过分 ty
1河北开学 0.1
2 0.1
精品文档
可编辑修改
3 0.2
精品文档
可编辑修改
4 0.3
5 0.2
6 0.1
解:
%v的值代表骰子面的编号
d=rand(1,1);
if d>=0&d<0.1
v=1
elif d>=0.1&d<0.2
v=2
elif d>=0.2&d<0.4
v=3
elif d>=0.4&d<0.7
v=4
elif d>=0.7&d<0.9
v=5
el
d=6
end
4. You arrive at the beach for a ven-day vacation and are dismayed
to learn that the local weather prediction is predicting a 50%
chance of rain every day. Using Monte Carlo simulation, predict
the chance that it rains at least three concutive(接连不断
的,连续而来的) days in your vacation.
解:
counter=0;
N=1e6;
for i=1:N
t=0;
p=rand(1,7);
for j=1:5
if p(j)>=0.5&p(j+1)>=0.5&p(j+2)国庆促销 >=0.5
t=1;
end
end
if t==1
counter=counter+1;
end
end
chance=counter/N
结果:chance =0.3676
5. (Optional) Using Monte Carlo simulation, write a Matlab program
to calculate the volume trapped between the two paraboloids(抛
物体)
z8xyandzx3y
2222
精品文档
可编辑修改
Note that the two paraboloids interct (相交)on the elliptic
cylinder
x2y4
22
解:
x=-10:0.1:10;
y=x;
[X,Y]=meshgrid(x,y);
Z=8-X.^2-Y.^2;
mesh(X,Y,Z)
hold on
马笕菜
z=X.^2+3*Y.^2;
mesh(X,Y,z)
ezplot('X.^2+2*Y.^2-4')
hold off
counter=0;
N=10000;
for i=1:N
x=-2+4*rand(1,1);
y=-sqrt(2)+2*sqrt(2)*rand(1,1);
z=-8+16*rand(1,1);
if x^2+2*y^2<4&z>8-x^2-y^2&z counter=counter+1; end end counter v收到的玫瑰花束怎么养
ol=counter/N鱼腥草功效
*4*2*sqrt(2)*16 精品文档 可编辑修改 X+2 Y-4 = 0 22 400 300 200 100 0 -100 -200 10 510 0 -5 Y -10 -10 -5 X 5 0 实验总结:本次实验主要学习了如何使用Matlab工具进行蒙特卡洛模拟,怀化学院
求出了某些曲边 梯形的面积,并利用蒙特卡罗方法求解了一些概率问题。通过本次实验了解到了蒙特卡罗方 法的应用及其原理。 . . 精品文档
本文发布于:2023-04-23 12:04:57,感谢您对本站的认可!
本文链接:https://www.wtabcd.cn/fanwen/fan/82/510798.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |