MATH 351 Homework 09
Due by Monday 05/12/25 by midnight PT. Submit a Jupyter
notebook to the GitHub repository for Homework 09.
Our final exam is scheduled for Monday 05/12/25 from 12 -
1.50pm in Holt 291. I'll be available then and there to
help you complete this assignment, if necessary.
We'll use Hamiltonian Monte Carlo to fit linear regression with the following dataset about finches. We aim to fit a model that predicts winglength
using a line on the variable middletoelength
.
- Write two Python functions, each with arguments
theta
anddata
. The first will calculate the following log density function. The second Python function shoulud return the gradient of the following log density function with respect to . - Use Hamiltonian monte carlo to estimate distributions of the unknown parameters .
- Calculate means and standard deviations of each parameter; don't forget to constrain (re-transform) before calculating means and standard deviations. Make plots for each parameter separately, traceplots and histograms. Make a scatter plot of the two coefficients and overlay a few sampled points from HMC. All calculations and plots should exclude the warmup points.