Question

In: Electrical Engineering

Simulate the experiment of rolling two dices for 1000 times. Generate the probability mass distributionfunction(PMF) for...

Simulate the experiment of rolling two dices for 1000 times. Generate the probability mass distributionfunction(PMF) for the sum of the two dices and plot the result using histogramcommand. Use two different methods for your simulations: Using for loops Using vectors and matrices in MATLAB

Solutions

Expert Solution

MATLAB code using for loop:

clc; clear all;
for i=1:1000
dice_1(i)=randi([1,6],1);
dice_2(i)=randi([1,6],1);
end
sum_of_dices = dice_1'+dice_2';
disp('dice_1 dice_2')
disp([dice_1' dice_2'])
disp('sum of dices is')
disp(sum_of_dices)
histogram(sum_of_dices)
xlabel('sum of the value on the faces of two dices')
ylabel('number of times the sum occured')
Output:



MATLAB code using vectors and matrices:

clc; clear all;
dice_1 = randi([1,6],[1000,1]);
dice_2 = randi([1,6],[1000,1]);
sum_of_dices = dice_1+dice_2;
disp('dice_1 dice_2')
disp([dice_1 dice_2])
disp('sum of dices is')
disp(sum_of_dices)
histogram(sum_of_dices)
xlabel('sum of the value on the faces of two dices')
ylabel('number of times the sum occured')


Related Solutions

R Exercise 1. (a) Simulate the rolling of two dice 10,000 times. (b) Identify which rolls...
R Exercise 1. (a) Simulate the rolling of two dice 10,000 times. (b) Identify which rolls of the dice are in the event A, the dice add up to a perfect square (4 or 9). Determine what proportion of the 10,000 rolls are in A. (c) Identify which rolls of the dice are in the event B, the dice add up to an even number. Determine what proportion of the 10,000 rolls are in B. (d) Find out which rolls...
Find the probability that: Rolling a fair die 3 times, at least two dice are less...
Find the probability that: Rolling a fair die 3 times, at least two dice are less than 4. Previous answers have suggested 0.875 (189 feasible cases/ 216 total cases). However, from simple trial and error we can see that there are more than 27 cases where this answers fails. For example is the first dice gets a 4 and the 2nd dice gets 4,5,6 and the last dice gets any number, there is already 18 cases here that are not...
Consider a random experiment of rolling 2 dice. What is probability of rolling a sum larger...
Consider a random experiment of rolling 2 dice. What is probability of rolling a sum larger than 9? Select the best answer. A. 0.5 B. 0.1667 C. 0.2333 D. None of the above
for the experiment of rolling an ordinary pair of dice, find the probability that the sum...
for the experiment of rolling an ordinary pair of dice, find the probability that the sum will be even or a multiple of 6. ( you may want to use a table showing the sum for each of the 36 equally likely outcomes.)
A die is weighted so that rolling a 1 is two times as likely as rolling...
A die is weighted so that rolling a 1 is two times as likely as rolling a 2, a 2 is two times likely as rolling a 3, a 3 is two times as likely as rolling a 4, a 4 is two times a likely as rolling a 5, and a 5 is two times as likely as rolling a 6. What is the probability of rolling an even number?
Consider rolling two regular, fair, 6-sided dice 10 times. What is the probability that at least...
Consider rolling two regular, fair, 6-sided dice 10 times. What is the probability that at least two of the rolls have a sum that exceeds 6. at least 7 of the rolls have a sum that is even. exactly three rolls have a sum equaling 5.
1.Plotting densitiesPlot the probability mass function (pmf) or probability density function (pdf) for eachof the following...
1.Plotting densitiesPlot the probability mass function (pmf) or probability density function (pdf) for eachof the following scenarios:(a) Consider abinomialrandom variable,X.i. Plot the pmf ofX∼Bin(n= 10,p= 0.3).ii. Plot the pmf ofX∼Bin(n= 10,p= 0.7).iii. Plot the pmf ofX∼Bin(n= 100,p= 0.3).iv. What happens to the shape of the pmf ofX∼Bin(n,p) whenpgets larger?v. What happens whenngets larger?(b) Consider ageometricrandom variable,Y.i. Plot the pmf ofY∼Geom(p= 0.1).ii. Plot the pmf ofY∼Geom(p= 0.5).iii. Plot the pmf ofY∼Geom(p= 0.8).iv. What happens to the shape of the pmf ofY∼Geom(p)...
Write a Java program to simulate the rolling of two dice. The application should use an...
Write a Java program to simulate the rolling of two dice. The application should use an object of class Random once to roll the first die and again to roll the second die. The sum of the two values should then be calculated. Each die can show an integer value from 1 to 6, so the sum of the values will vary from 2 to 12. Your application should roll the dice 36,000,000 times. Store the results of each roll...
Java Programming Activity Description: This lab requires you to simulate the rolling of two dice. Two...
Java Programming Activity Description: This lab requires you to simulate the rolling of two dice. Two dice consisting of 6 sides are rolled. Write a program that simulates this. The user will be asked if he/she wishes to continue the roll of dice. If the answer is, “Y” or “y”, then your application will continue to roll the two dice. Each roll of the dice must occur 6 times, each time the user agrees to continue (see sample output). Use...
Summarize key data distribution concepts including probability mass functions (PMF), probability density functions (PDF), and cumulative...
Summarize key data distribution concepts including probability mass functions (PMF), probability density functions (PDF), and cumulative distribution functions (CDF). Based on an organization or any organization you are most familiar with, provide an example of a PMF, an example of a PDF, and an example of a CDF, based on the type of data used in the organization. How would you summarize each of these to someone who is not familiar with each of these functions?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT