You don't have your for-loops set up properly. You are trying to find the probability that five consecutive 7's occur in 100 rolls of two dice. So, one trial consists of 100 rolls of two dice. Your Monte Carlo simulation should have an outer loop running the number of trials, and inside this loop is one trial consisting of 100 rolls of the dice where you look for five consecutive 7's. An outline something like this based on your nomenclature:
p=1/6;
ntrials = 100000;
N=100;
sumseven=zeros(ntrials,1);
for m=1:ntrials
l=0;
for k=1:N
end
end
p_sumseven=sum(sumseven(:))/ntrials;
Best Answer