26 Assignment 3

Due 11:59pm Sunday February 5

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

You may complete this assignment with a partner (i.e., max group size of 2 people). If you chose to work with a partner you only need to submit one assignment, but please make sure both of your names are on it. You may participate in a learning group of any size to complete the assignment, but please submit your own work.

Make sure to show all of your work and computer code, so that your mathematical and numerical results are easily reproducible. In the most basic sense, this is equivalent to “showing your work” as you would with pencil and paper in a mathematics course.

Please save the file as a pdf and name it Yourlastname_Assignment3. Upload this file to Canvas.

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.