options(width = 40)
library(tidyverse); library(plotly)
## ── Attaching core tidyverse packages ───
## ✔ dplyr 1.1.4 ✔ readr 2.1.5
## ✔ forcats 1.0.0 ✔ stringr 1.5.1
## ✔ ggplot2 4.0.0 ✔ tibble 3.3.0
## ✔ lubridate 1.9.4 ✔ tidyr 1.3.1
## ✔ purrr 1.1.0
## ── Conflicts ── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
##
## Attaching package: 'plotly'
##
##
## The following object is masked from 'package:ggplot2':
##
## last_plot
##
##
## The following object is masked from 'package:stats':
##
## filter
##
##
## The following object is masked from 'package:graphics':
##
## layout
knitr::opts_chunk$set(echo=FALSE, message=FALSE, warning=FALSE, comment=NA,
fig.width=7, fig.height=3.6, out.width='100%',
fig.align='center', dev='png', dpi=96)
options(width=60)
set.seed(42)
n <- 25; nsim <- 10000
xbar <- replicate(nsim, mean(rnorm(n)))
z <- sqrt(n)*xbar
sim <- tibble(z=z,xbar=z/sqrt(n))
sdx <- 1/sqrt(n)