Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Overview This homework assignment is the first assignment designed to get you familiar with the programming basics. Your objective is to perform a series of
Overview
This homework assignment is the first assignment designed to get you
familiar with the programming basics. Your objective is to perform a series
of simulated "dice rolls", perform a basic statistical analysis, and plot the
results. You must do this assignment in MATLAB, but keep in mind
that you should also use whatever programming language your group is using
for the research topic.
For extra credit: You may do this assignment
in both MATLAB and PYTHON languages
Before you begin the coding, write an introduction explaining what you anticipate the results will be
What can you say about the probabilities of outcomes in each case:
What should the probabilities be for each of the faces numbers for the single die roll?
What should the probabilities be for each of the combinations of the sum of the two dice roll?
What can you say about the sample means for each case:
How do the sample means change as we increase the number of rolls?
What should the mean be for the single die roll?
What should the mean be for the sum of the two dice roll?
Having thought about the expected outcomes and put your predictions in the introduction, move on to writing the code.
You will first "roll" an individual dice and times, calculating the
mean, standard deviation, histogram, CFD and PDF for each set.
Then, you will "roll" two dice, adding together their sums, and times. Again, calculating
the mean, standard deviation, histogram, CFD and PDF for each set of rolls.
Requirements
To fulfill this project, you must successfully program a script that utilizes
several different functions and loops to simulate dice rolls and calculate
the statistics. Each function should have a practical name, be easy to read
and understand, and function. You should also comment appropriately
throughout the program such that someone else could understand what is
occurring.
Submission
You will submit the following to the Canvas assignment box:
A summary MS WORD document with introduction, tables of the statistical parameters, and
copies of the generated histograms
Your welldocumented code source files. Make sure the main script is named properly.
Note that any submitted code needs to be able to be executed without
any errors. Any additional libraries need to be able to be installed using a
package manager like pip.
The main script should be named in the following format:
h#ASSIGNMENTNAMELAST NAMEEXTENSION for example, hdicerollweaver.
image.png
Extra Credit
If you are willing to dig in a little bit more, this project has a couple of opportunities to earn extra credit points
at the discretion of the instructor. First, you may do this assignment in both Python and MATLAB. Being able to
work with multiple programming languages is an extremely useful skill. Python and MATLAB are also close
enough in syntax that the code should not have to change much between them.
Additionally, you may write up to three different operations with the dice rolling and provide the same output
for each. For points of extra credit each, you may write functions that subtract, multiply, and divide the rolls
of two dice for and rolls. You will only be granted the extra credit points if the full output for each
operation is provided!
Psuedocode
For those that are new to programming, a suggested code layout is given below in psuedocode to guide you.
Function: Roll One Die
Argument: iterations
Initialize zeroes array of length iterations
For every iteration
Sample a random integer from
Add sample to array
Returns: array of random samples, mean of array, stdev of array
Function: Roll Two Dice and Sum
Argument: iterations
Initialize zeroes array of length iterations
For every iteration
Sample two random integers from and add together
Add the summation to array
Returns: array of summed samples, mean of array, stdev of array
Calculate array, mean, and stdev for single rolls
Calculate array, mean, and stdev for single rolls
Generate output table for single rolls and print
Create singular die roll figure with two subplots
Plot bar graph for die rolls
Plot bar graph for die rolls
Show figure
Calculate array, mean, stdev for summed dice rolls
Calculate array, mean, stdev for summed dice rolls
Generate output table for summed rolls and print
Create summed dice roll figure with two subplots
Plot bar graph for summed dice rolls
Plot bar graph for summed dice rolls
Show figure
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started