Labfans是一个针对大学生、工程师和科研工作者的技术社区。 | 论坛首页 | 联系我们(Contact Us) |
![]() |
![]() |
#2 |
游客
帖子: n/a
|
![]()
clear all
clc counter=0;i=1; x=rand(1,100000);n=length(x); for i=1:n if x(i)<=1/2&x(i)>=0 counter=counter+1; else counter=counter; end i=i+1; end p=counter/n 首先,所谓蒙特卡洛就是一个随机算法,随机肯定每一次结果不同,第二,你的代码中有个错误rand, |
![]() |