25 Assignment 2

Due 11:59pm Sunday January 29

The purpose of this assignment is to explore and reinforce concepts in Chapters 1-3 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_Assignment2. 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. Solve the integral \(\int_{0}^1 [a]da\) analytically (i.e., using pencil and paper). Make sure to show your work. You may embed a photo of your hand written work to show your steps.

  2. Approximate the integral \(\int_{0}^1 [a]da\) numerically using the quadrature method with \(m=40\) equally spaced support points (see pg. 12 in BBM2L). Make sure to show all the computer code needed to reproduce your numerical results.

  3. Approximate the integral \(\int_{0}^1 [a]da\) using Monte Carlo integration with \(K=100\) draws (see pg. 18 in BBM2L). Make sure to show all the computer code needed to reproduce your numerical results.

  4. Write 3-5 sentences comparing the results you obtained in questions 1-3 and explain why the analytical and numerical results differ.

  5. Solve the integral \(\int_{0}^1 a[a]da\) analytically. Verify that your answer matches that of the expected value of a beta distribution with \(\alpha=2\) and \(\beta=1\).

  6. Approximate the integral \(\int_{0}^1 a[a]da\) numerically using the quadrature method with \(m=40\) equally spaced support points.

  7. Approximate the integral \(\int_{0}^1 a[a]da\) using Monte Carlo integration with \(K=100\) draws.

  8. This question is for bonus points only (i.e., extra credit). Solve the integral \(\int_{0}^1 \text{log}\left(\frac{1}{\mathrm{sin}(a)}\right)[a]da\) analytically.

  9. Approximate the integral \(\int_{0}^1 \text{log}\left(\frac{1}{\mathrm{sin}(a)}\right)[a]da\) using Monte Carlo integration with \(K=100\) draws.