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 come up less often than a 10-supposedly in the experience of gamblers.

  1. 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.

  2. Can you conclude from your simulations that the gamblers were correct?

  3. Answer:

nine<-0
ten<-0

for (i in c(1:1000000)) {
  tot<-0
  for (j in c(1:3)){
    temp<-sample(1:6,1)
    tot<-tot+temp
  }
  ifelse(tot==9,nine<-nine+1,ifelse(tot==10,ten<-ten+1,a<-0))
}

nine
## [1] 115175
ten
## [1] 126184
ninepr<-0
tenpr<-0

for (i in c(1:6)) {
  for (j in c(1:6)){
    for (b in c(1:6)){
    tot<-i+j+b
    ifelse(tot==9,ninepr<-ninepr+1,ifelse(tot==10,tenpr<-tenpr+1,a<-0))
  }
 } 
}

ninepr
## [1] 25
tenpr
## [1] 27
  1. Yes, gamblers were correct that 9 will appear fewer times, but there is nothing suprising about it. Probability of 9 is 25/6^3 versus probability of 10 is 27/6^3.