$\theta=\int_{0}^{2}3e^{-3x}dx$ Compute theta using Monte-Carlo Method

90 Views Asked by At

$\theta=\int_{0}^{2}3e^{-3x}dx$

Using Monte-Carlo method estimate the confidence intervals for the integral above. Use a distribution different from the uniform distribution to minimize the confidence intervals.

I tried using variable substitute so $\theta=\int_{0}^{1}6e^{-6t}dt$ and using the beta distribution(1,6) the plots seem to agree but the estimate for $\theta$ seems to be way to big, here is the R output:

> integral2<-function(n) {
+   x<-runif(n)
+   fy<-dbeta(x,1,6)
+   g_y<-6*exp(1)^(-6*x)
+   hy<-(g_y/fy)
+   sdg_y<-sd(g_y)
+   theta<-mean(hy)
+   sdtheta<-sqrt(sum((hy-theta)^2)/(n-1))
+   print(max(hy))
+   print(theta)
+   print(sqrt(sum((hy-theta)^2)/(n-1)))
+ 
+   return(c(theta-sdtheta*qnorm(0.975)/sqrt(n),theta+sdtheta*qnorm(0.975)/sqrt(n)))
+ }
> integral2(10000)
[1] 1.484229e+17 #max(hy)
[1] 2.123842e+13 #theta
[1] 1.608726e+15 #sdtheta
[1] -1.029203e+13  5.276887e+13 #confidence interval for theta