Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Checking the Accuracy of a Monte Carlo Integration. Use Monte Carlo to estimate

ID: 3205842 • Letter: C

Question

Checking the Accuracy of a Monte Carlo Integration. Use Monte Carlo to estimate the integral theta = integral_2^4 (3x^2 - 2x -10)dx. Perform this calculation m = 1000 times each for Monte Carlo sample sizes of n = 1000, n = 10,000, and n = 100,000. For each n, plot a histogram of theta_(n)1, ..., theta_(n)m, and calculate the mean squared error of the estimate, MSE_(n) = 1/m sigma_i=1^m (theta_(n)i - theta_0), where theta_(n)i is the i^th MC estimate of theta for sample size theta_0 and theta_0 is the true value of the integral theta.

Explanation / Answer

The R output is

The exact R program is

thetaI <- function(x) 3*x^2-2*x-10
theta0 <- integrate(thetaI,lower=2,upper=4)$value
theta0

m <- 1000
n <- c(1e3,1e4,1e5)
y <- function(x) (x-2)/2
Iy <- matrix(0,nrow=m,ncol=3)
for(i in 1:3){
for(j in 1:m){
    u <- runif(n[i])
    Iy[j,i] <- mean(2*(3*(2*u+2)^2-2*(2*u+2)-10))
}
}
mean(Iy[,1]-theta0)^2
mean(Iy[,2]-theta0)^2
mean(Iy[,3]-theta0)^2

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote