On a roll of two dice, a total of seven occurs with probability 1=6. In 100 rolls of the dice, what is the probability that five consecutive rolls of seven will occur? Model using Monte Carlo simulation.
…………………………………………..
p=1/6;N=100;sumseven=zeros(N,1);for m=1:Nl=0;for k=1:5x=rand;if x<pl=l+1;elsel=0;endif l==5sumseven(m)=1;break;endendendp_sumseven=sum(sumseven(:))/N;fprintf('Probability of a 5 consecutive rolls of 7: p=%6.5f\n',p_sumseven);
………………………………….
not sure about (if x < p)
Best Answer