In the early 1600s, Galileo was asked to explain the fact that,although the number of triples of integers from 1 to 6 with sum 9 is the same as the number of such triples with sum 10, when three dice are rolled, a 9 seemed to comeup less often than a 10-supposedly in the experience of gamblers.
(a) Write a program to simulate the roll of three dice a large number of times and keep track of the proportion of times that the sum is 9 and the proportion of times it is 10.
(b) Can you conclude from your simulations that the gamblers were correct?
sumulateDice = function(n)
{
set.seed(123)
diceSum = list(0)
for(i in 0:n)
{
dice1 = sample(1:6, size=1, replace=TRUE)
dice2 = sample(1:6, size=1, replace=TRUE)
dice3 = sample(1:6, size=1, replace=TRUE)
sumDice = dice1 + dice2 + dice3
diceSum[i] = sumDice
}
return (diceSum)
}
print("Three Dice Roll for 100 times")
## [1] "Three Dice Roll for 100 times"
diceSum = sumulateDice(100)
print(paste("Proportion of 9 = ", length(diceSum[diceSum == 9])/length(diceSum)))
## [1] "Proportion of 9 = 0.14"
print(paste("Proportion of 10 = ", length(diceSum[diceSum == 10])/length(diceSum)))
## [1] "Proportion of 10 = 0.16"
print("Three Dice Roll for 1000 times")
## [1] "Three Dice Roll for 1000 times"
diceSum = sumulateDice(1000)
print(paste("Proportion of 9 = ", length(diceSum[diceSum == 9])/length(diceSum)))
## [1] "Proportion of 9 = 0.131"
print(paste("Proportion of 10 = ", length(diceSum[diceSum == 10])/length(diceSum)))
## [1] "Proportion of 10 = 0.133"
print("Three Dice Roll for 10000 times")
## [1] "Three Dice Roll for 10000 times"
diceSum = sumulateDice(10000)
print(paste("Proportion of 9 = ", length(diceSum[diceSum == 9])/length(diceSum)))
## [1] "Proportion of 9 = 0.1218"
print(paste("Proportion of 10 = ", length(diceSum[diceSum == 10])/length(diceSum)))
## [1] "Proportion of 10 = 0.1233"
Conclusion: From the three simulations above, we can conclude that proportions of 9 and 10 are almost the same. The difference is in-significant as the no of simulations increases