ggplot(dice_sims, aes(x = ybar)) +geom_histogram(bins =40) +facet_wrap(~n, scales ="free_y") +labs(title ="sampling distribution of ybar for dice rolls",x ="ybar",y ="count")
As you can see everything is all centered around 3.5 for all n as it should be and variability decreases as n increases and the shape becomes more normal (also i’m so sorry my computer won’t install purrrfect so i’m trying to do without it and will be visiting you sometime next week to figure this out bare with me please)
we only need one input (n) to simulate each ybar value, so map() is enough; pmap() is for functions that need multiple inputs per row. every mean is almost 3.5 as it should and as the variability is 35/12n doing the math you get n=20: 0.14583, n = 40: 0.073, n=80: 0.036458, n=160: 0.018229 which every variability is almost straight on the dot