% LMex020206_4th.m
% Example 2.2.7 page 28 in 
% Larsen & Marx (2006) Introduction to Mathematical Statistics, 4th edition
% Written by Eugene.Gallagher@umb.edu 1/14/11 31
% http://alpha.es.umb.edu/faculty/edg/files/edgwebp.html
% A singe card is drawn from a poker deck. A is the event that an Ace has
% been selected and B is the event "Heart is drawn" Find A intersection B
% and A union B. Let C be the event a club is drawn. Find B U C and B^C.
deckn=repmat(1:13,1,4);
deckf=repmat('HCDS',1,13);
Ai=find(deckn==1);Bi=find(deckf=='H');
i=intersect(Ai,Bi);
fprintf('The intersection of A & B has %2.0f outcome(s):\n',length(i))
fprintf('%1c%2.0f\n',[deckf(i)' deckn(i)']')
i=union(Ai,Bi);
fprintf('The union of A & B has %2.0f outcome(s):\n',length(i))
fprintf('%1c%2.0f\n',[deckf(i)' deckn(i)']')
Ci=find(deckf=='C');
i=union(Bi,Ci);
fprintf('The union of B & C has %2.0f outcome(s):\n',length(i))
fprintf('%1c%2.0f\n',[deckf(i)' deckn(i)']')
i=intersect(Bi,Ci);
fprintf('The intersection of B & C has %2.0f outcome(s):\n',length(i))
fprintf('%1c%2.0f\n',[deckf(i)' deckn(i)']')




