Question: Here is the Question you told me that needs a lot of work. Please help me to solve this question, or at least few parts.

Here is the Question you told me that needs a lot of work. Please help me to solve this question, or at least few parts.

Here is the Question you told me that needs a lot

1. The dice game of Yahtzee is played with five regular six-sided dice. The players throw the dice one at the time and try to get different combinations of die values. The highest number of points is given by five-of-a-kind, which is also called Yahtzee. A player may throw the dice three times at each turn: one original throw and two times when the player may keep some of the dice and reroll the other ones. In this mini-project, we will not limit ourselves to three throws, but wonder: How large is the probability to obtain five-of-a-kind using a certain number of throws? What is the average number of throws needed to obtain five-of-a-kind? One way of measuring the variations in the number of throws is the variance. You should write a MATLAB function Yahtzee that simulates a large number of attempts to obtain five-of-a-kind. The function should draw a histogram over the number of throws that are needed. a. Several Throws 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? b. Count the Number of Each Outcome Write a function that takes the outcome of a throw with five dice as argument and returns a vector with the number of ones, twos, and so on. Example: The outcome [1 4 2 2 4] should yield [1 2 0 2 0 0] (one one, two twos, no threes, two fours, and no fives or sixes). c. Find Out Which Outcome is Most Common Modify the function from the last step to return the most common outcome (ones, twos, threes, . . . ). The vector previously returned should come in handy. If there are two pairs in the result, just return one of them. It doesn't matter which of them is returned, thus you choose if you like small or large values. Test the function and make sure that it works properly! Example: The outcome [4 5 4 4 1] should yield 4 (four is the most common out- come). The outcome [1 4 2 2 4] should yield either 2 or 4 (you decide). d. Find the Dice to Throw Again With the knowledge of the most common outcome it is time to decide which dice to save and which to throw again. There are two ways to do this: 1) One alternative is to modify the function from the last step so that it returns a vector containing the indices of the dice to throw again; that is, the dice not showing the number computed in Part 'c'. Test the function! The dice [4 5 4 4 1] should yield [2 5] (throw dice number 2 and 5 again). The dice [1 4 2 2 4] should yield [1 2 5] or [1 3 4] (you decide). 2) The second alternative is to put the dice to save at the beginning of the dice vector. Since the value that the dice you save (from Part 'c') and how many such dice you have (from Part 'b') is known, it is possible to create a vector with the correct number of dice and values. After modifying the function make sure to test it before you proceed! Example: The outcome [4 5 4 4 1] should yield [4 4 4 * *] (where * will be thrown again and so the value is unimportant). The outcome [1 4 2 2 4] should yield either [2 2 * * *] or [4 4 * * *] (you decide). e. Five-of-a-Kind Now extend the function to throw the selected dice again, and to repeat this procedure until five-of-a kind is obtained (i.e., there are no dice to throw again). Let the function return how many throws were needed. Before continuing with the next step make sure that the function works. One way to do this is to, just for now, display and study the result after each throw. Be careful with the situation when you first get two-of-a-kind in one throw and on the next throw you get three of another kind, then you should save the one with three-of-akind instead of the one you saved at first. f. Monte-Carlo Simulation A Monte-Carlo simulation means that that you perform an experiment many times in order to get an idea of how the underlying probability function looks. Write a (new) function that throws dice until you have obtained five-of-a-kind many times. Your code should be able to make 10000 experiments in one or a few minutes, otherwise you need to optimize your code. It may be good to write out something with disp so that one can follow the progress. Store the number of throws needed in each experiment in a vector. Plot a histogram to illustrate the result (i.e., the number of throws needed). The histogram bins should have width 1. The function should take the number of experiments as an input argument. g. Compute Estimates of the Expected Value and Variance Modify the function to also return estimations of the expected value and variance for the number of throws. The average value is an estimate of the expected value, and a formula to estimate the variance is given in Section 3. In this case xi is the number of throws needed in experiment i, and n is the number of experiments. Ask the teacher if you cannot work out how to use the formulas! Section 3 also presents the theoretical expected value and variance. Make sure that the estimates from your function are close to the exact values

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Mathematics Questions!