2025-10-19
## # A tibble: 3 × 3 ## n emp_mean emp_sd ## <dbl> <dbl> <dbl> ## 1 5 1.00 0.445 ## 2 30 1.00 0.185 ## 3 100 0.999 0.0988
dens_df <- sample_means |>
group_by(n) |>
reframe({
d <- density(mean)
tibble(x = d$x, y =d$y)
})
ggplot(dens_df, aes(x, y, color = factor(n), group = n)) +
geom_line(linewidth = 1.1) +
geom_vline(xintercept = 1, linetype = 3, linewidth = 0.7) +
scale_color_manual(values = c("5"="#5B8FD9","30"="#58B88A","100"="#C76C5B"),
name = "Sample size n") +
labs(title = "Sample Means Tighten as n Increases",
subtitle = "Population: Exponential(1); dashed = true mean (μ = 1)",
x = expression(bar(X)), y = "Density") +
theme_minimal(base_size = 14) +
theme(legend.position = "top", panel.grid.minor = element_blank())
## Warning: 'layout' objects don't have these attributes: 'scence' ## Valid attributes include: ## '_deprecated', 'activeshape', 'annotations', 'autosize', 'autotypenumbers', 'calendar', 'clickmode', 'coloraxis', 'colorscale', 'colorway', 'computed', 'datarevision', 'dragmode', 'editrevision', 'editType', 'font', 'geo', 'grid', 'height', 'hidesources', 'hoverdistance', 'hoverlabel', 'hovermode', 'images', 'legend', 'mapbox', 'margin', 'meta', 'metasrc', 'modebar', 'newshape', 'paper_bgcolor', 'plot_bgcolor', 'polar', 'scene', 'selectdirection', 'selectionrevision', 'separators', 'shapes', 'showlegend', 'sliders', 'smith', 'spikedistance', 'template', 'ternary', 'title', 'transition', 'uirevision', 'uniformtext', 'updatemenus', 'width', 'xaxis', 'yaxis', 'boxmode', 'barmode', 'bargap', 'mapType'