results = zeros(2,10); % first value = first draw, 10th = 10th draw for i = 1:100000 % 100000 trials balls = randperm(16,16); % if the value is less than <= 6 it is white % if the value is > 6 it is red if(balls(1) > 6) % check for value of the first ball results(1,i) = 1; % store a 1 if it is red end if(balls(10) > 6) % check for value of the tenth ball results(2,i) = 1; % store a 1 if it is red end end probs = sum(results,2)/i; % divide the sum of the total number of red balls drawn for each ball position, and divide by total trials disp('The suggested probability of the first ball being red (found through sampling) is') disp(probs(1)) disp('The suggested probability of the tenth ball being red (found through sampling) is') disp(probs(2))