# Step 1: Set up the problem
p_success <- 1/6
p_failure <- 5/6
# Step 2: Calculate the probability using the CCDF
p_4or_more <- (1 - p_failure^3)
p_4or_more
# Step 3: Simulate 10,000 random samples using the geometric distribution
set.seed(42) # Set the seed for reproducibility
n <- 10000
simulations <- rgeom(n, prob = p_success) + 1
# Step 4: Create a histogram using ggplot2
library(ggplot2)
ggplot(data.frame(simulations), aes(x = simulations)) +
geom_histogram(binwidth = 1, color = "black", fill = "skyblue") +
labs(title = "Waiting for the 6: A Board Game Enthusiast's Journey",
x = "Number of Rolls to Get the First 6",
y = "Frequency") +
theme_minimal()
# Step 5: Describe the distribution