solution3 - Homework 3 solution 1 Problem 1 We can just use...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Homework 3 solution 1 Problem 1 We can just use the algorithm described in HW2: Step1: Generate x uniform(0,1) distribution. Step2: Generate u from uniform(0,1). Step3: Accept x if u < f ( x )1 { 0 <x< 1 } c , and reject x otherwise. R code: x<-NULL num=0 while(num<100) { y<-runif(1) u<-runif(1) if(u<=dweibull(y,5,3)/dweibull(1,5,3)) { x<-c(x,y) num<-num+1 } } mean(x) sd(x)/10 In my run, the estimate for the posterior mean is 0.8367417, and the standard error is 0.01437222. 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 Problem 2 a) Naive Monte Carlo method: Step1: Draw 1000 samples x i from uniform(0,1). Step2: Estimate E [ sin ( x 2 )] by the sample mean of sin ( x 2 i ) and estimate the standard error by sd ( sin ( x 2 i )) / 1000. R code: x=runif(1000) m_naive=mean(sin(x^2)) sd_naive=sd(sin(x^2))/sqrt(1000) m_naive sd_naive In my run, the estimate for E [ sin ( x 2 )] is 0.3092447, and the standard error is 0.0083495. b) Importance sampling method: Step1: Draw 1000 samples x i from g ( x ). Step2: Calculate the weights as
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 10/24/2010 for the course STAT 428 taught by Professor Chen during the Spring '08 term at University of Illinois, Urbana Champaign.

Page1 / 6

solution3 - Homework 3 solution 1 Problem 1 We can just use...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online