Part A: In the first part of this assignment, you will be simulating the rolling of a balanced six-faced die. You will roll the die 900 times and examine the first 30, 150, 300 and 600 rolls, as well as all 900 rolls. For each of these numbers of rolls you will compute the observed probabilities of obtaining each of the six outcomes, and compare these probabilities with the real probabilities of obtaining these outcomes.
Assignment 1a
Your MATLAB file should be named Assignment1a.m. This program should do the following:
1. Using the random number function, randi, generate a 10 ´ 900 array of random integers between 1 and 6 in the array X. The 10 rows represent ten different experiments and the 900 columns represent 900 trials (i.e., rolls).
2. Using the randi function, randomly select a row from X.
3. Count the number of times each of these outcomes occurs. You need to obtain the number of times each of these outcomes occurs in the first 30 trials (i.e., the first 30 values of X), as well as the first 150, 300, 600, and in all 900 values of this row.
4. Next, you need to convert these frequencies into probabilities by dividing by the corresponding number of trials. You also need to have available the real probabilities associated with each of the six outcomes.
5. Generate a plot of probability (y-axis) versus outcome (x-axis). There should be 6 lines plotted: one each for the 30, 150, 300, 600, and 900 trial situations and one line that represents the real probability values for each of these six outcomes. The line associated with the real probabilities for each of the six outcomes should be a solid line. Make sure the two axes are labeled and the plot is titled. Also, ensure that the x-axis only contains the six outcome values, and that there is a legend. Many of these formatting adjustments can be made after the plot is generated while working with the menu options available with the figure plot.
6. Run your program three times. Each run should result in a different plot, so you should have three plots.
Answer the following questions:
(a) In general, how different are the three plots from one another (give an example to illustrate your point)?
(b) Why should there be variability across these plots?
(c) Which trial number (30, 150, 300, 600, or 900) appears to be the most variable across the three plots and which appears to be the least variable, and what is the basis for your assessment?
(d) Overall, at which number of trials do the observed probabilities appear to begin to converge to the real probability values?
Part B: In this second part of the assignment, you will be simulating rolling two balanced six-faced dice. You will roll the two dice 900 times and examine the first 30, 150, 300 and 600 rolls, as well as all 900 rolls. For each of these numbers of rolls, you will compute the observed probabilities of obtaining outcomes of two, seven, and eleven, and compare these probabilities with the real probabilities of getting each of these outcomes.
Assignment 1b
Your MATLAB file should be named Assignment1b.m. This program will be similar to Assignment 1a.m, with the primary exceptions being that it will involve simulating rolling two dice and examining three (2, 7, and 11) instead of six outcomes. This program should do the following:
1. Using the random number function, randi, generate a 10 ´ 900 array of random integers between 1 and 6 in the array X. The 10 rows represent ten different experiments and the 900 columns represent 900 trials (i.e., rolls).
2. Using the randi function, randomly select two rows from X.
3. Ensure that that the two rows randomly selected differ.
4. Define the array Y as the sum of these two rows.
5. Count the number of times a two, seven, or eleven occurs in the first 30 trials (the first 30 values of Y), as well as the first 150, 300, 600, and in all 900 values of Y.
6. Convert these frequencies into probabilities by dividing by the corresponding number of trials. You also need to have available the real probabilities associated with each of these three outcomes (2, 7, and 11).
7. Generate a plot of probability (y-axis) versus outcome (x-axis). There should be 6 lines plotted: one each for the 30, 150, 300, 600, and 900 trial situations and one line that represents the real probability values for each of these three outcomes. The line associated with the real probabilities for each of the three outcomes should be solid Make sure the axes are labeled, the plot is titled, the x-axis only contains the three outcome values, and that there is a legend.
7. As in Assignment 1a, run your program three times to generate three plots.
Answer the following questions:
(a) Does there appear to be a relationship between the real probability value and the variability in the estimates? Explain.
(b) Overall, at which number of trials do the observed probabilities appear to converge with the real probabilities?
(c) Consider the procedure that was used in this simulation study (for both Parts A and B). For any given simulation run that generated a plot, would you consider the five different curves associated with the different trial numbers (30, 150, 300, 600, and 900) on any given plot to be independent of one another? Why or why not?
(d) How could the procedure of the simulation have been improved?
No comments:
Post a Comment