################################################################################ # # Rejection method & Sampling importance resampling (SIR) # ################################################################################ # # HEDIBERT FREITAS LOPES # Associate Professor of Econometrics and Statistics # The University of Chicago Booth School of Business # 5807 South Woodlawn Avenue # Chicago, Illinois, 60637 # Email : hlopes@ChicagoBooth.edu # URL: http://faculty.chicagobooth.edu/hedibert.lopes # ################################################################################ xxx = seq(-6,6,length=1000) # Rejection methods: Uniform proposal par(mfrow=c(1,2)) set.seed(1231354) Au = 7.89 N = 10000 draw1 = runif(N,-10,10) accept = dnorm(draw1)/(Au*0.05) u = runif(N) draws1 = draw1[u