In this exercise you will familiarize yourself with the Method Marko Chain Monte Carlo (Metropolis Hastings algorithm). You should use similar analysis to validate your own MCMC algorithm.
Step 1: Download the demo function made available through Mathworks File Exchange.
Step 2: Run the script metropolis_hastings.m
- Note the frequency of generated samples. Which samples are generated more frequently?
- Note the fit of the generated histogram and the probability density.
Step 3: Run the script metropolis_hastings2.m. It will take a while to execute.
- Note how the algorithm samples a 2D distribution. Note the differences in acceptance rates.
- Important. Note the autocorrelation function. How many samples should be discarded and why?