Concept map / Roll a fair die

Share

Roll a fair die

Select the faces in an event and compare its probability with the proportion of rolls that match.

Prerequisites Probability

1Build an event, then roll

Each face of a fair die has probability 1/6. An event is a set of faces, such as “an even number”: 2, 4 and 6. Its probability is 3/6, so in 60 rolls you expect about 30 even numbers. Will you get exactly 30? This page builds on probability as a long-run proportion.

Pick the faces in your event and roll. Changing the faces rescores the rolls you already have, so you can compare events on the same data.

No rolls yet.

Faces in your event

The small number is how often that face has come up.

Event probability
3/6 = 1/2 (50.0%)
Observed proportion
No rolls yet
012345123456Number of rollsFace (green faces are in the event)

Your event {2, 4, 6} contains 3 of the 6 faces, so its probability is 3/6 = 1/2 (50.0%). Roll the die to compare it with what happens.

More controls

2At least one six in four rolls

Roll a fair die four times. What is the probability of rolling at least one six?

3Faces over 6, matches over rolls

When every face is equally likely, the probability of an event A is the number of faces in it, |A|, over 6. The observed proportion p^\hat p is the number of matching rolls, m, over the number of rolls, n. Point at a symbol to see its part of the lab light up.

P(A)=∣A∣6p^=mnP(A) = \frac{\htmlClass{term-k}{|A|}}{6} \qquad \hat p = \frac{\htmlClass{term-m}{m}}{\htmlClass{term-n}{n}}

For {2, 4, 6}, P(A) = 3/6 = 0.500. Roll the die to compute p^\hat p.

How far p^\hat p usually strays from P(A)

Roll the die first. The answer depends on the number of rolls.

4Check yourself

The tasks use the die and the face buttons in section 1 and tick themselves when you meet them.

  • Roll at least 30 times, then switch the event to the odd faces {1, 3, 5}. Compare its observed proportion with that of {2, 4, 6}.Now: No rolls yet
  • Make the event certain: select every face and roll at least once.Now: Event probability 3/6 = 1/2, no rolls yet
  • Choose an event with probability 1/3. Roll at least 100 times, and keep rolling until its observed proportion is within 0.010 of 0.333.Now: Event probability 3/6 = 1/2, observed none yet after 0 rolls

5Count matches in R

sample() rolls the die and %in% counts the rolls that land in the event. Each roll matches or not, independently and with the same chance, so the number of matches is binomial and dbinom() gives its exact probabilities, including the answer to the prediction.

Roll a die and count matches to an eventShow the code
# Roll a fair die 600 times
set.seed(1)
rolls <- sample(1:6, 600, replace = TRUE)
table(rolls)

# The event "even number" contains faces 2, 4 and 6
event <- c(2, 4, 6)
matches <- sum(rolls %in% event)
c(probability = length(event) / 6, observed = matches / 600)

# Matches in 600 rolls follow a binomial(600, 1/2).
# Chance the count lands within 20 of the expected 300:
round(sum(dbinom(280:320, size = 600, prob = 1/2)), 3)

# Chance of at least one six in four rolls
round(1 - dbinom(0, size = 4, prob = 1/6), 4)

Uses base R only.

What events on a die show