# The options message = FALSE, and echo = FALSE # prevent this code and its output showing up in the # knit document library(tidyverse) library(here)
# This reads in the pre-saved simulation runs_big <- read_rds(here("results", "sim-output.rds"))
A random sequence of H's and T's is generated by tossing a fair coin $n = 20$ times. What's the expected length of the longest run of consecutive heads or tails?
Taken from Tijms, Henk. Probability: A Lively Introduction. Cambridge University Press, 2017
How does the expected length of the longest run vary with the number of coinflips, $n$?
How does the answer change if the coin isn't fair?
How does the variance of our estimate vary with the number of simulations we do?
A simulation study was conducted to explore the answers to these questions ... blah blah
runs_big %>% ggplot(aes(x = n, y = mean_max_length, color = factor(prob))) + geom_pointrange(aes( ymin = mean_max_length - 1.96*sd_max_length/sqrt(n_sims), ymax = mean_max_length + 1.96*sd_max_length/sqrt(n_sims))) + geom_line() + facet_wrap(~ n_sims, labeller = "label_both") + labs(x = "Estimated expected longest run", y = "Coin toss sequence length", color = "Probability of heads") + scale_color_brewer(palette = "Set1") + theme_bw()
Unsurprising the longer the coin toss sequence the longest the expected longest run ... blah blah
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.