Question: Write a function file that simulates a throw with a given number of dice and returns the result. Let the number of dice be an
Write a function file that simulates a throw with a given number of dice and returns the result. Let the number of dice be an input argument to the function and return the result as a vector with the results of the throw.
Hint: Create a vector with random numbers in the interval 0 to 1, one number for each die, multiply by 6, and round upwards.
Make sure that the probability for a die to show 1, 2, 3, 4, 5, or 6 is identical. One way to verify this is to throw many dice, e.g., 1000, and plot a histogram of the outcome (see help hist). How is the histogram supposed to look?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
