% LMex030311_4th.m
% Larsen & Marx (2006) p 160
% Find F_xt for random variable X, defined as the larger of
% two dice.
% Written by Eugene Gallagher, Eugene.Gallagher@umb.edu
% http://alpha.es.umb.edu/faculty/edg/files/edgwebp.html
% Written 10/7/10, revised 1/12/10
% Brute force enumeration, but note that the book provides
% an intuitive solution;
% Nothing fancy: just creating a 36-outcome sample sapce
die=1:6;
SampleSpace=max(repmat(die,6,1),repmat(die',1,6));
SampleSpace=SampleSpace(:); % creates a 36-outcome vector
lSS=length(SampleSpace);
% creates the cumulative distribution function F_x(t)
Fxt=sum(repmat(SampleSpace,1,6)<=repmat(die,lSS,1))/lSS
% Graph
t=0:0.01:6;
 % need to use equation for Fxt from page 160 in text
 % rounding down to nearest integer with floor will create
 % stepped cdf.
Fxt=floor(t).^2./36;
plot(t,Fxt);ylabel('F_X(t)'),xlabel('t');title('Example 3.3.11');
figure(gcf);