\[\int_{1}^{\infty} \frac{x^2}{\sqrt{2\pi}}e^{-x^2/2}dx\]
m <- 10000
theta.hat <- se <- numeric(5)
g <- function(x) {
((x^2)/(sqrt(2*pi))*exp(-(x^2/2))*(x>1))
}
# f0
x <- runif(m)
fg <- g(x)
theta.hat[1] <- mean(fg)
se[1] <- sd(fg)
# f1
x <- rexp(m)
fg <- g(x)/exp(-x)
theta.hat[2] <- mean(fg)
se[2] <- sd(fg)
# f2
x <- rcauchy(m)
fg <- g(x)/dcauchy(x)
theta.hat[3] <- mean(fg)
se[3] <- sd(fg)
# f3
u <- runif(m)
x<- log(1 - u * (1 - exp(-1)))
theta.hat[4] <- mean(fg)
se[4] <- sd(fg)
# f4
u <- runif(m)
x <- tan(pi * u /4)
fg <- g(x) / (4 / ((1 + x^2) * pi))
theta.hat[5] <- mean(fg)
se[5] <- sd(fg)
rbind(theta.hat, se)
## [,1] [,2] [,3] [,4] [,5]
## theta.hat 0 0.3974737 0.4075516 0.4075516 0
## se 0 0.5853573 0.9633940 0.9633940 0
\(f_1\) produces the lowest variance, therfore our estimate will be 0.3974737.