作业帮 > 综合 > 作业

用MATLAB统计rand中的概率

来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/05/28 07:51:52
用MATLAB统计rand中的概率
统计0到1/3,1/3到2/3、2/3到1分别出现的次数(用MATLAB)
代码如下:
count1 = 0;
count2 = 0;
count3 = 0;
Testlength = 100000;%rand函数测试次数
for i = 1:Testlength
tmp = rand(1,1);
if tmp>=0&&tmp=1/3&&tmp=2/3&&tmp