Skip to content

Instantly share code, notes, and snippets.

@sieste
Created January 31, 2020 08:15
Show Gist options
  • Save sieste/d3ff8f793f5316f141b339324053de68 to your computer and use it in GitHub Desktop.
Save sieste/d3ff8f793f5316f141b339324053de68 to your computer and use it in GitHub Desktop.
n = 10
theta = 1
alpha = 0.05
lo = up = numeric(10000)
for (i in 1:10000) {
x = rexp(n, 1/theta)
lo[i] = ((1-alpha)^(-1/n) - 1) * sum(x)
up[i] = (alpha^(-1/n) - 1) * sum(x)
}
xo = rexp(10000, 1/theta)
mean(x0 < lo) # "outlier" low
mean(x0 > up) # "outlier" high
mean(x0 > lo & x0 < up) # coverage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment