Last active
April 10, 2021 01:47
-
-
Save dlebauer/5b147d619f35aa4edcf0e3af1e7f23b7 to your computer and use it in GitHub Desktop.
how much easier is it to estimate a mean than a minimum?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
n_sim <- 10000 | |
mu <- -10 | |
sd <- 2 | |
n <- 30 | |
z <- array(NA, c(3,n_sim)) | |
for(i in 1:n_sim){ | |
x <- rnorm(n, mu, sd) | |
z[1, i] <- mean(x) | |
z[2, i] <- min(x) | |
z[] | |
} | |
mean(z[1,]) | |
mean(z[2,]) | |
sd(z[1,]) | |
sd(z[2,]) | |
sd(z[1,])/mean(z[1,]) | |
sd(z[2,])/mean(z[2,]) | |
# "True" n-year min | |
qnorm(1/n, mu, sd) | |
# Median absolute bias (MAB) | |
median(abs(z[1,]-mu)) | |
median(abs(z[2,] - qnorm(1/n, mu, sd))) | |
median(abs(z[2,] - qnorm(1/n, mu, sd))) / median(abs(z[1,] - mu)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment