Thanks for showing some work. Here is how one could approach the first task:
n = 10000;
m = 100;
PROB = zeros(1,m);
for ii = 1:m
X = ceil(6*rand(1,n));
Y = ceil(6*rand(1,n));
Z = X+Y;
PROB(ii) = sum(Z==7)/n;
end
plot(1:m,PROB,'b*')
hold on
line([1 m],mean(PROB)*ones(1,2),'color','r')
line([1 m],[1 1]./6,'color','k')
legend({'Trial Values';'Trials Mean';'Theory'})
The second task uses some skill learned in the first, so try to understand what I did and what went wrong in what you did. Also, look at the MATLAB HIST and HISTC functions.
Best Answer