Question: Implement the Metropolis algorithm. Parameter for binomial distribution is probability of success theta [0, 1], n = 20. Assume the observed data vector gives Sn
Implement the Metropolis algorithm. Parameter for binomial distribution is probability
of success theta [0, 1], n = 20. Assume the observed data vector gives Sn = 5.
(a) (5 points) Assume the prior distribution as in our lecture, pi(theta) = 2 cos^2(4pi*theta). Gener-
ate samples from the posterior distribution pi(theta|Y ). Discretize thetato 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 pi(thata|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 Epi(thata|Y )f[
thata-1/2]^2 =
sum
(theta - 1/2)^pi(theta|Y )d theta.
(c) (10 points) Now assume the the prior distribution is given by pi(theta) 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
