A use the monte carlo method with n 100 and n 1000 to


Write R code for the following Question:

a. Use the Monte Carlo method with n = 100 and n = 1000 to estimate integral top=1 bottom=0 cos(2πx) dx. Compare the estimates to the exact answer.

b. Use Monte Carlo to evaluate integral top=1 bottom=0 cos(2πx 2) dx. Can you find the exact answer?

Thus far I have:

#Estimation of f=integral(cos(2piX)dx) from x=0,1

#generate random values from appropriate ranges

x<-data.frame(x=runif(n,min=0,max=1)

#evaluate at f

f=integral(cos(2(pi)X)dx)

#Approximate by averaging with appropriate scaling

(1/16)*(1)*(3/32)*mean(f)

Solution Preview :

Prepared by a verified Expert
Business Economics: A use the monte carlo method with n 100 and n 1000 to
Reference No:- TGS02862784

Now Priced at $10 (50% Discount)

Recommended (92%)

Rated (4.4/5)