You play a game in which you throw two dice (6-sided) and select the highest value. Repeat it many times. What is the average of the results?
itr <- 100000
play <- replicate(itr, {
first <- sample(c(1,2,3,4,5,6), 1, replace = TRUE, prob = c(1/6,1/6,1/6,1/6,1/6,1/6))
second <- sample(c(1,2,3,4,5,6), 1, replace = TRUE, prob = c(1/6,1/6,1/6,1/6,1/6,1/6))
max(first, second)
})
mean(play)
The answer is 4.47
What happens if you do the same game on two 20-sided dice?
itr <- 100000
play <- replicate(itr, {
first <- sample(seq(1,20), 1, replace = TRUE, prob = rep(1/20,20))
second <- sample(seq(1,20), 1, replace = TRUE, prob = rep(1/20,20))
max(first, second)
})
mean(play)
You get 13.83