What would be the simulation for the following statement?: A fair coin is tossed until the first head occurs. Do this Z = 10 times and plot the relative frequencies of this occurring at the ith toss, for suitable values of i.
조회 수: 1 (최근 30일)
이전 댓글 표시
A fair coin is tossed until the first head occurs. Do this Z = 10 times and plot the relative frequencies of this occurring at the ith toss, for suitable values of i.
댓글 수: 0
채택된 답변
ragesh r menon
2014년 4월 1일
clear all
clc
close all
z=10;%number of times you want to repeat the experiment
s=zeros(0,z);
for j=1:z
coin=[];
i=1;
coin(i)=round(rand(1,1));
while(coin(i)==0)
i=i+1;
coin(i)=round(rand(1,1));
end
coin
s(j)=length(coin);
end
stem(s)
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 MuPAD에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!