网站大量收购独家精品文档,联系QQ:2885784924

MATLAB实验报告6.doc

  1. 1、本文档共4页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
MATLAB实验报告6

Using Monte Carlo simulation, write a Matlab program to calculate an approximation to ( by considering the number of random points selected inside the quarter circle where the quarter circle is taken to be inside the square count=0; n=10000; for i=1:n x(i)=rand(1); y(i)=sqrt(1-(x(i))^2); z=rand(1); if z=y(i) count=count+1; end; end; s=count/n PI=4*s 结果:s =0.7869 PI =3.1476 s =0.7819 PI =3.1276 s =0.7828 PI =3.1312 Using Monte Carlo simulation, write a Matlab program to calculate the volume of an ellipsoid(椭球体) count=0; n=10000; for i=1:n x(i)=sqrt(32)*rand(1); y(i)=8*rand(1); z(i)=sqrt(8*16-4*(x(i))^2-2*(y(i))^2); u=sqrt(128)*rand(1); if u=z(i) count=count+1; end; end; v=4*count/n*sqrt(32*64*128) 结果: v = 1.0758e+003 v = 1.0627e+003 v = 1.0818e+003 3、Use Monte Carlo simulation to simulate the rolls of an unfair die. Assume the die is biased according to the following empirical distribution: Roll Value Probability 1 0.1 2 0.1 3 0.2 4 0.3 5 0.2 6 0.1 设pi(i=1,2,3,4,5,6)表示色子显示i点的概率。 count=[0 0 0 0 0 0]; n=12000; for i=1:n x(i)=rand(1); if x(i)=0.1 count(1)=count(1)+1; elseif x(i)0.1 x(i)=0.2 count(2)=count(2)+1; elseif x(i)0.2 x(i)=0.4 count(3)=count(3)+1; elseif x(i)0.4 x(i)=0.7 count(4)=count(4)+1; elseif x(i)0.7 x(i)=0.9 count(5)=count(5)+1; else count(6)=count(6)+1; end; end; for k=1:6 p(k)=count(k)/n; end for i=1:6 fprintf(p%d:%f ,i,p(i)); end 结果: p1:0.105083 p2:0.097583 p3:0.202917 p4:0.294667 p5:0.203333 p6:0.096417 p1:0.095750 p2:0.098667 p3:0.208333 p4:0.297000 p5:0.201250 p6:0.099000 p1:0.098417 p2:0.100000 p3:0.198417 p4:0.299917 p5:0.194250 p6:0.109000 4.You arrive at the beach for a seven-day vacation and are dismayed to learn that the local weather prediction is predicting a 50% chance

文档评论(0)

haihang2017 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档