solution7 - Homework 7 solution 1 Problem 1 For this...

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

View Full Document Right Arrow Icon
Homework 7 solution 1 Problem 1 For this problem, all you need to do is to change r=0.3 if you are using the code in lab 6. R code: x2<-5 x1s<-NULL x2s<-NULL r<-0.5 for (i in 1:10000) { # Update x1 through conditional distribution of x1|x2 x1<-rnorm(1,r*x2,sqrt(1-r^2)) x1s<-c(x1s,x1) # Update x2 through conditional distribution of x2|x1 x2<-rnorm(1,r*x1,sqrt(1-r^2)) x2s<-c(x2s,x2) } mean(x1s) par(mfrow=c(2,1)) hist(x1s,main="histogram of samples simulated by Gibbs") hist(rnorm(10000),main="histogram of independent samples") 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
In my run, the estimated mean for X 1 is 0.01414714. histogram of samples simulated by Gibbs x1s Frequency -4 -2 0 2 4 0 1000 2000 histogram of independent samples rnorm(10000) -4 -2 0 2 4 Figure 1: Histograms for problem 1 2
Background image of page 2
2 Problem 2 Part 1: Algorithm: Step1: Initialize the X vector. Step2: For i = 1 , 2 ,..., d , calculate the conditional probability of X t +1 i = 1 | X t 1 ,...,X t i - 1 ,X t i +1 ,..., X t d , p 1 = π ( X i =1 ,X 1 = X t 1 ,...,X i -
Background image of page 3

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

View Full DocumentRight Arrow Icon
Image of page 4
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

solution7 - Homework 7 solution 1 Problem 1 For this...

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

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