Simulate 10000 games
Now, let's simulate 10000 games and answer the following: since 2 and 12 are equally unlikely, how often does either a 2 or a 12 get rolled more than twice within a game?
Basic strategy indicates that the spaces with 2 or 12 should be avoided because they are the least probable, and although this is true theoretically, here we will investigate how surprising it really should be if they end up coming up more frequently than expected. The roll_dice function from previous exercises has been preloaded for you.
Deze oefening maakt deel uit van de cursus
Probability Puzzles in R
Oefeninstructies
- Use the
replicatefunction to roll two dice 60 times. - Use a compound condition to check whether either a 2 or 12 was rolled more than twice.
- Print your estimated probability of rolling a 2 or 12 more than twice within a game.
Praktische interactieve oefening
Probeer deze oefening eens door deze voorbeeldcode in te vullen.
set.seed(1)
counter <- 0
for(i in 1:10000){
# Roll two dice 60 times
rolls <- ___
# Check whether 2 or 12 was rolled more than twice
if(___){
counter <- counter + 1
}
}
# Print the answer
print(___)