Question: 4. Bayesian inference using Metropolis-Hastings algorithm. (25 points) Implement the Metropolis algorithm. Parameter for binomial distribution is probability of success o ( [0, 1], n

4. Bayesian inference using Metropolis-Hastings algorithm. (25 points) Implement the Metropolis algorithm. Parameter for binomial distribution is probability of success o ( [0, 1], n = 20. Assume the observed data vector gives S, = 5. (a) (5 points) Assume the prior distribution as in our lecture, (() = 2 cos-(4TO). Gener- ate samples from the posterior distribution (#|Y). Discretize / to be a uniform grid of points [0, 1/10, ..., 1]. Run the chain for n = 100, 500, 1000, and 5000 time steps, respectively. For each time step, compare the empirical distributions with the desired posterior distribution (0|Y). (Hint: you may use ergodicity: hence the distribution of states can be estimated from one sample path when the number of time steps is large (e.g. 500).) (b) (10 points) Following from the previous question, evaluate the mean of the poste- rior distribution (this gives an estimator for the parameter value), and E"(){[e - 1/212} = S(0 - 1/2)2n ( 0 |Y ) de. (c) (10 points) Now assume the the prior distribution is given by (@) is a uniform distribution over [0, 1]. Repeat the above questions, (a) and (b)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
