0 = Tails and 1 = Heads
library(matlib)
library(MASS)
library(dplyr)
library(ggplot2)
library(patchwork)
Observations:
The first plot checks out in that as n increase, the proportion of heads minus 1/2 approaches zero
Similar to James Mundy’s findings was that, as n increases, the # of heads minus the 1/2 the # of tosses increased
counter-intuitively? As you can see in the simulation, as n gets bigger, so does the differences; not sure why?
set.seed(12345)
out1 <- c()
out2 <- c()
iter <- seq(100, 100000, 100)
for(n in iter) {
num_heads <- rbinom(n, 1, 0.5)
out1 <- c(out1, sum(num_heads)/n - 0.5)
out2 <- c(out2, sum(num_heads) - (n/2))
}
df <- tibble(iter=iter, run1=out1, run2=out2)
p1 <- df %>% ggplot() + geom_line(aes(x=iter, y=run1), colour="blue") + theme_minimal()
p2 <- df %>% ggplot() + geom_line(aes(x=iter, y=run2), colour="red") + theme_minimal()
p1 / p2