# Setup
source("https://pbreheny.org/7110/f26/notes/fun.R")

# Convergence of xbar squared
n <- 100
N <- 1000
col <- scales::alpha('gray40', 0.2)
ylim <- c(-1.5, 1.5)
at <- seq(4, 10, 2)
lab <- 2^at

x <- rasym(n, N, 100, mean = TRUE)
matplot(
  log2(as.numeric(rownames(x))),
  sqrt(1) * x^2,
  type = 'l',
  col = col,
  lty = 1,
  xaxt = 'n',
  bty = 'n',
  las = 1,
  xlab = 'n',
  ylab = expression(bar(X)^2 - mu^2),
  ylim = ylim
)
axis(1, at = at, label = lab)
mtext(expression(mu == 0))

x <- rasym(n, N, 100, mu = 1, mean = TRUE)
nn <- as.numeric(rownames(x))
matplot(
  log2(nn),
  sqrt(1) * (x^2 - 1),
  type = 'l',
  col = col,
  lty = 1,
  xaxt = 'n',
  bty = 'n',
  las = 1,
  xlab = 'n',
  ylab = expression(bar(X)^2 - mu^2),
  ylim = ylim
)
axis(1, at = at, label = lab)
mtext(expression(mu == 1))

