Q1. Recollect the first two definitions of probability that we have covered in c
ID: 3586479 • Letter: Q
Question
Q1. Recollect the first two definitions of probability that we have covered in class 1. Probability of an event is the relative frequency of occurrence of the event when a random experiment is repeated multiple times 2. Probability of an event is the ratio of the count of the number of outcomes of interest and the total number of outcomes that are possible (assuming that all outcomes are equally likely to occur) Now, our first task (using MATLAB) is to verify if the two definitions give the same answer, if yes, under what conditions and if no, then what are the conditions. So, find the probability of getting a. An outcome of a 5 when you roll a six sided dice b. An outcome of 3, 4, or 5 when you roll a six sided dice c. A head when you toss a fair coin d. Two heads when you toss two fair coins e. A sum of more than 9 when you roll two six sided dice f. An ace when you draw one card from a deck of 52 cards Proceed as follows: Define the Sample Space ii. Define the event of interest iiDetermine the probability of the event of interest using the enumeration process iv. Verify if the probability is the same as that obtained using the relative frequency approach. For the relative frequency approach, assume that you are repeating the experiment 1000, 2000, 10000 number of times. Plot the graph of relative frequency of the outcome of interest (y axis) vs. the number of iterations. v. Submit a word documents with your group members names, the graphs for the problems in the assignment, as well as the Matlab code you wrote. Please write down you observations about the equivalence of (and differences in) the two definitions of probability. Please Note: You will need to take a printout of the assignment and hand it over in class.Explanation / Answer
i=1000:1000:10000;
pro=zeros(1,length(i));
%a
%probability calculated by hand=1/6
for k=1:length(i)
n=0;
for j=1:i(k)
outcome=randi(6);
if outcome==5
n=1+n;
end
end
pro(k)=n/i(k);
end
figure
plot(i,pro)
title('probability of getting 5 in a dice roll')
xlabel('Number of iterations')
ylabel('probability')
grid on
%b
%probability calculated by hand=3/6=.5
for k=1:length(i)
n=0;
for j=1:i(k)
outcome=randi(6);
if outcome==5 || outcome ==3 ||outcome==4
n=1+n;
end
end
pro(k)=n/i(k);
end
figure
plot(i,pro)
title('probability of getting 3,4, or 5 in a dice roll')
xlabel('Number of iterations')
ylabel('probability')
grid on
%c
%probability calculated by hand=1/2=.5
for k=1:length(i)
n=0;
for j=1:i(k)
outcome=randi(2);
if outcome==1
n=1+n;
end
end
pro(k)=n/i(k);
end
figure
plot(i,pro)
title('probability of getting a head in a coin toss')
xlabel('Number of iterations')
ylabel('probability')
grid on
%d
%probability calculated by hand=(1/2 *1/2) =.25
for k=1:length(i)
n=0;
for j=1:i(k)
outcome1=randi(2,[1,2]);
if sum(outcome1)==4
n=1+n;
end
end
pro(k)=n/i(k);
end
figure
plot(i,pro)
title('probability of getting 2 heads in 2 coin toss')
xlabel('Number of iterations')
ylabel('probability')
grid on
%e
%probability calculated by hand=4/36=1/9=.111 {(5,5),(5,6),(6,5),(6,6)}
for k=1:length(i)
n=0;
for j=1:i(k)
outcome=randi(6,[1,2]);
if sum(outcome)>9
n=1+n;
end
end
pro(k)=n/i(k);
end
figure
plot(i,pro)
title('probability of getting a sum of more than 9 in a two dice roll')
xlabel('Number of iterations')
ylabel('probability')
grid on
%f
%probability calculated by hand=4/52=1/13=.0769
for k=1:length(i)
n=0;
for j=1:i(k)
outcome=randi(52);
if outcome==1 || outcome ==14 ||outcome==27||outcome==40
n=1+n;
end
end
pro(k)=n/i(k);
end
figure
plot(i,pro)
title('probability of getting an ace from deck of 52 cards')
xlabel('Number of iterations')
ylabel('probability')
grid on
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.