13 Activity 3

The purpose of this activity is to explore and reinforce concepts in Chapter 4 of Bringing Bayesian Models to Life.

You are encouraged to work with others students in the class to complete this activity.

For this assignment let \([a]\) be a beta distribution with \(\alpha=2\) and \(\beta=1\) (i.e., \(a\sim\text{beta}(\alpha=2,\beta=1)\)).

  1. Use a Metropolis-Hastings algorithm to draw 5000 samples from \([a]\) (see bottom of pg. 25 in BBM2L). For this example, use a uniform PDF for the proposal distribution and a starting value of 0.01. Before you start this problem write out and simplify the Metropolis-Hastings ratio. Show all of your steps for this.

  2. Discard the first 1000 samples from the 5000 Monte Carlo samples you drew in question 1. Then make a histogram of the remaining 4000 samples to represent the distribution of \(a\). Make sure to pay special attention to what is on the y-axis (i.e., frequency vs. density) and make sure to provide sensible lables for both the x and y axes.

  3. Discard the first 1000 samples from the 5000 Monte Carlo samples you drew in question 1. Then calculate the mean of the remaining 4000 samples you drew in question 1. Although it might not be obvious, you are implicitly approximating an integral. Write out the integral that you are approximating.

  4. Look at the first 50 samples from the 5000 Monte Carlo samples you drew in question 1. You should see repeated “random draws” of the same number (i.e., the same random number will appear multiple times in a row). In 3-5 sentences explain why this happens and how it might influence the approximations in questions 2 and 3.