% LMex020204_4th.m
% Example 2.2.1 p 24 in
% Larsen & Marx (2006) Introduction to Mathematical Statistics, 4th edition
% Written by Eugene.Gallagher@umb.edu for EEOS601 1/13/11
% http://alpha.es.umb.edu/faculty/edg/files/edgwebp.html
% A coin is tossed until the first head appears
% This doesn't directly address the issue posed in the text, but instead
% shows another type of control loop, capable, in theory of producing an
% infinite string of coin tosses (all heads)
coin=['H';'T']
% create the sample space
% S=cell(1); 
i=1;
face='H';
S=' ';
while face=='H'
    face=coin(randi(2));
    S(i)=face;
    i=i+1;
end
disp('The sample space, S:')
S
