library(tidyverse)
set.seed(301)
flips <- sample(c(0, 1), 5000, replace = TRUE)
tibble(
n = seq_along(flips),
running = cummean(flips)
) %>%
ggplot(aes(n, running)) +
geom_line(color = "#2E86C1") +
geom_hline(yintercept = 0.5,
color = "#E74C3C",
linetype = "dashed") +
coord_cartesian(ylim = c(0.3, 0.7)) +
labs(title = "Proportion of heads settles at 0.5",
x = "Number of flips", y = NULL) +
theme_minimal(base_size = 11)


















