Questions: Introduction to probability
Before attempting these questions, it is highly recommended that you read Guide: Introduction to probability.
Q1
The questions below will be based on a sweet shop called Cantor’s Confectionery.
1.1. Express each of the following events’ sample spaces in the form of tree diagrams.
A standard Cantor’s Gummy Bag contains 12 gummies in total: 2 gummy rings, 3 gummy worms, and 7 gummy bears. You draw one gummy from the bag.
You draw two gummies with replacement from the bag in Q1.1.
You draw two gummies without replacement from the bag in Q1.1.
1.2. There are two jelly bean jars in Cantor’s Confectionery. The first jar has 10 cola flavoured jelly beans, 10 strawberry flavoured jelly beans, and 10 blueberry flavoured jelly beans. The second jar has 13 cola flavoured jelly beans, 20 strawberry flavoured jelly beans, and 5 blueberry flavoured jelly beans. You take a random jelly bean from the first jar, then you take a random jelly bean from the second jar. Express the sample space and probabilities of this in the form of a tree diagram.
1.3. Identify whether the events in Q1.1.(b), Q1.1.(c), and Q1.2. are dependent or independent.
Q2
Use your answers from Q1 to calculate the probabilities of the following events.
2.1.
In Q1.1.(a), find \(\mathbb{P}(\textsf{gummy bear}')\).
In Q1.1.(b), find \(\mathbb{P}(\textsf{gummy ring,gummy ring})\).
In Q1.1.(c), find \(\mathbb{P}(\textsf{gummy bear,gummy worm})\).
2.2. In Q1.2., find \(\mathbb{P}(\textsf{cola,strawberry})\).
Q3
The questions below will be based on an unbiased spinner evenly split into 4 sections of different colors: red, black, white, and green.
3.1. You spin the spinner 60 times and find that it lands on red 10 times, it lands on black 13 times, it lands on white 17 times, and it lands on green 20 times. Is this an example of theoretical probability or experimental probability?
3.2. Based on the information from Q3.1., calculate the probability of the spinner not landing on white.
3.3. Consider the other type of probability that was excluded from your answer in Q3.1. Calculate this type of probability for the spinner landing on red.
3.4. How can the law of large numbers be applied to this spinner?
Q4
The questions below will be based on a fictional scenario where you are participating in a tabletop roleplaying game, in which the gameplay heavily depends on the results of dice rolls.
4.1. To succeed in stealing a jewel, you must roll a 20-sided die and get a number above 12. Represent the sample space of this in the form of a list, then calculate the probability of succeeding.
4.2. You are attacking a dragon. This time, you have to roll a 5-sided die, then 3 points will be added to the result of your die roll. Adding this up will determine how much damage is done to the dragon. Represent the sample space of this in the form of a list, then calculate the probability that at least 5 points of damage is done to the dragon.
4.3. You roll a 4-sided die twice to determine your success. If at least one of the rolls results in a 4, you will succeed in committing the action. Represent the sample space of this in the form of a table, then calculate the probability of failing the action.
4.4. You roll a 9-sided die and a 4-sided die. The sum of these two dice rolls determines your skill level. Represent the sample space of this in the form of a table, then calculate the probability that your skill level will exceed 9 points.
#| '!! shinylive warning !!': |
#| shinylive does not work in self-contained HTML documents.
#| Please set `embed-resources: false` in your metadata.
#| standalone: true
#| viewerHeight: 420
library(shiny)
library(bslib)
# Hard-coded hex color for the button (a nice teal color)
BUTTON_COLOR <- "#3F6BB6"
ui <- page_fluid(
title = "Dice roller with n sides",
card(
card_header("Dice roller with n sides"),
card_body(
# Use a row layout for landscape orientation
layout_columns(
col_widths = c(4, 4, 4), # Equal width columns
# Left column: Description and settings
card(
card_body(
div(
style = "display: flex; flex-direction: column; height: 100%; justify-content: center;",
p("Click the button to roll a die.", style = "font-size: 18px;"),
br(),
div(
style = "background-color: #f8f9fa; padding: 15px; border-radius: 5px;",
h5("Die Settings:"),
numericInput("sides", "Number of sides:", value = 6, min = 3, step = 1),
helpText("Enter a number 3 or greater")
)
)
)
),
# Middle column: Dice display
card(
card_body(
div(
style = "height: 100%; display: flex; align-items: center; justify-content: center;",
div(
style = "font-size: 120px; line-height: 1; width: 150px; height: 150px;
margin: 0 auto; border: 2px solid #ccc; border-radius: 15px;
display: flex; align-items: center; justify-content: center;",
textOutput("diceValue")
)
)
)
),
# Right column: Button
card(
card_body(
div(
style = "display: flex; height: 100%; align-items: center; justify-content: center;",
actionButton("rollButton", "Roll Dice", class = "btn-lg",
style = paste0("background-color: ", BUTTON_COLOR, "; color: white;"))
)
)
)
)
)
)
)
server <- function(input, output, session) {
# Validate the sides input
sides <- reactive({
sides_value <- input$sides
# Ensure it's a valid number (integer ≥ 3)
if (!is.numeric(sides_value) || sides_value < 3 || sides_value != round(sides_value)) {
# Default to 6 if invalid
return(6)
}
return(as.integer(sides_value))
})
# Create a reactive value to store the current roll
diceValue <- reactiveVal(1)
# Initialize with a valid roll
observe({
# Update the initial value when the number of sides changes
current_sides <- sides()
current_value <- diceValue()
# If current value is out of range for the new number of sides, reset it
if (current_value > current_sides) {
diceValue(sample(1:current_sides, 1))
}
})
# Update the dice value when the roll button is clicked
observeEvent(input$rollButton, {
current_sides <- sides()
# Rolling animation - this is a simplified version using invalidateLater
# to simulate the dice rolling
for(i in 1:5) {
invalidateLater(i * 100)
}
# Final roll
diceValue(sample(1:current_sides, 1))
})
# Display the current dice value
output$diceValue <- renderText({
diceValue()
})
}
# Run the application
shinyApp(ui = ui, server = server)
After attempting the questions above, please click this link to find the answers.
Version history and licensing
v1.0: initial version created 04/25 by Michelle Arnetta as part of a University of St Andrews VIP project.