When a fair die is rolled, the number uppermost is equally likely to be any inte
ID: 3874815 • Letter: W
Question
When a fair die is rolled, the number uppermost is equally likely to be any integer between 1 and 6. MATLAB randi function generates uniformly distributed pseudorandom integers. Use this documented MATLAB program (dietoss.m simulate a fair die roll of N = 10, 100, 1000 and 10,000 times. For each trial, count the number of sixes thrown by constructing a logical vector and counting the number of times 6 appears. Use MATLAB's vectorizing commands for logical operators in your solution. Estimate the probability of throwing a six by dividing the number of sixes by 10, 100, 1000 and 10,000 respectively. Compare each to the theoretical expected value of 1/6.Explanation / Answer
1
We used the following code to generate our outputs:
%---------------------------CODE------------------------------%
N = 10000
dieThrows = [];
for i = 1:N
dieThrows = [dieThrows randi(6)];
end
count6 = sum(dieThrows == 6);
fprintf('In %d out of %d throws we got 6 ', count6, N);
%-------------------------------END------------------------------%
So as we can see the when
N = 10, 6 occured 20% of time
N = 100, 6 occured 22% of time
N = 1000, 6 occured 17.7% of time
N = 10000, 6 occured 17.27% of time
whereas our expected value was 1/6 or 16.67%.
We can observe that, as the N grew, percentage of 6 came closer to expected value.
Champ this is the answer to question 1. I hope you like it. If incase you are facing any difficulties with the answer, please feel free to comment below. I shall be glad to help you.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.