docx

School

University of Kentucky *

*We aren’t endorsed by this school

Course

3871

Subject

Statistics

Date

Nov 24, 2024

Type

docx

Pages

8

Uploaded by PresidentBook5853

Report
Monte Carlo Simulation_ Task 3. Importance Sampling: There are many ways to compute or estimate я. A very simple estimation procedure is via importance sampling. Suppose that samples 21,...,n were obtained uniformly inside a square with side length 2r (see diagram), where each x=(x), x)) for i = 1,..., n. (2) Now define bi 1 if x is also inside the circle of radius r, and bi 0 otherwise. Then = p=b is an estimate of the ratio of the area of the circle to the area of the square. = Given that we know the true value of p for this setting, we can then obtain an estimate of π.
(a) Show that the estimate of is given by 4p.
(b) Estimate ? using n 1,000 samples ? = 4 x ni a Where ni = number of points in the circle a= sample ni = 780 a= 1000 ? = 4 x 780 1000 ? = 4 x 0.78 ? = 3.12 The graphical presentation of the Monte Carlo simulation for Pi ( ?) is shown below.
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
(c) Using the central limit theorem, determine the Monte Carlo sampling variability of (i.e. derive the asymptotic distribution of # as n gets large).
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
(d) Construct a histogram of 1,000 estimates of, each based on n = 1,000 samples. Superimpose the Monte Carlo sampling variability distribution from part (c) under the assumption that the true value for p=0.7854, and verify that it matches the experimental result. p=0.7854 u=runif(1000) w=dnorm(u,0.5,0.01)^p cat("The ESS is",ess(w),"\n") # ESS ≈ 48 The ESS is 35.9872 xx=seq(0,1,length=950) a=sample(u,1000,replace=T,prob=w/sum(w)) hist(a,xlab="u",ylab="density",probability=T,ylim=c(0,50), + main="histogram of 1,000 estimates") lines(xx,dnorm(xx,0.5,0.01),type='l') lines(xx,dnorm(xx,0.5,0.01)^p,lty=2,col=2)
(e) Without using the true value of p, based on the Monte Carlo sampling variability, determine what sample size, n, is needed if we require to estimate π to within 0.01 with at least 95% probability. rm(list=ls()) par(mfrow=c(1,1)) xx=seq(0,1,length=350) plot(xx,dnorm(xx,0.5,0.01),type='l',xlab="u",ylab="density") u=runif(1000) w=dnorm(u,0.5,0.01) ess=function(w) { W=w/sum(w); return(1/sum(W^2))} cat("The ESS is",ess(w),"\n") The effective sample size would be 27.22