Sie sind auf Seite 1von 1

Function Explanation

The first part of the function runs the code 10000 times to represent 10000 simulations.
It then enters a random number between 1 and 6 into the rows of Zero matrix called
Dice_Roll for every run of the simulation.
A new array r(i:0) is created and a one is entered in the rows in which the value that was
rolled is equal to the value entered by the user, and then the number of correct guesses
is summed in the command Number_correct=sum(Dice_Roll(i,0)==Value_of_die)
+sum(Dice_Roll(1,:)==1),
this is included because 1s are considered wild.
The second part of the code keeps track of how many die had the value that was
desired. This was done with the introduced counter J, and conditional statements.
The number of occurrences is then divided by 10000 to determine the probability.
The final section of the code is used to calculate the final results.
It does this by using a for loop, as the user inputed number of die as a the start of the for
loop.
The decimal is then changed to a percentage because it is prettier.

Das könnte Ihnen auch gefallen