Dice probabilities with simulation in R
No math involved
NOTE: For my articles published outside of medium.com, please see below:
Rolling a fair die gives each of the six sides the same probability. So, each side has a probability of 1/6 in one event, or when we roll it. Dice probabilties become more interesting when we roll multiple dice and look for the probability of various events. Let’s explore some of them with simulation in R.
Probability of the sum of the numbers of two dice
For this, you roll two dice simultaneously or sequentially such that each dice rolls independently. You then sum up the numbers shown by the two dice. In R, you can compute an approximation of the probability by simulating the rolling of dice over and over in a for() loop.
Probability of rolling 2 (or any specific number between 1 and 6) in both dice
The probability is 0.0291
Probability of rolling 3 (or any specific number between 1 and 6) in 3 dice
The probability is 0.00469
Probability of the same number occurring at least twice in 5 dice
The probability is 0.9082
Probability of a specific number occuring at least twice in 5 dice
Note that this problem is not same as the probability of the same number occurring at least twice in 5 dice solved above. In the example above, any number can be shown by at least two of the five rolled dice and it will be considered a success. For example, number 2 in the first roll and number 6 in the second roll make both rolls a success if those numbers were shown by 2 or more dice. However, in this problem, you pick a number upfront and compute the probability of at least two occurrences of the specific number when 5 dice are rolled.
The probability is 0.19696
Probability of the same number occuring at least three times in 5 dice
The probability is 0.21068.