Suppose you are a board game maker, and you want to give players a higher probab
ID: 3792437 • Letter: S
Question
Suppose you are a board game maker, and you want to give players a higher probability of rolling larger numbers. Originally you had them roll three six-sided dice and add their results. The new approach will have the player roll four dice and add the totals of the three highest valued dice. Write a program that counts through every permutation of four six-sided dice and find the total of the three highest valued dice. Calculate the permutations of rolling four six-sided dice Plot a histogram of the totals Calculate the mean and standard deviation of the totals Plot a histogram of the values for the lowest valued, second-lowest, third-lowest, and highest value diceExplanation / Answer
function prob=sumDicePDF(n,k)
if n < 1 || k < n || k > 6*n
display('Bad Input! Try Again.');
n = input('n = ');
k = input('k = ');
prob=sumDicePDF(n,k);
return;
end
%If there is only one dice return probability 1/6
if n == 1
prob = 1/6;
return;
end
valuesMatix = zeros(n - 1,6*n); %Define new matrix size n-1,n*6
%with zeros
for i = 1:6
valuesMatix(1,i) = 1/6;
end
for i = 2:n - 1
for j = i:6*i
probForSpecPlace = 0;
for l = 1:6
if j - l > 0 %Check if value out of range becouse
probForSpecPlace = probForSpecPlace + valuesMatix(i - 1,j - l)*1/6;
end
end
valuesMatix(i,j) = probForSpecPlace;
end
end
prob = 0; %Define the probability to 0
for i = 1:6
if k - i > 0
prob = prob + valuesMatix(n - 1,k - i)*1/6;
end
end
end