Docsity

Bayesian Inference - Machine Learning - Homework 5 | CS 5350, Assignments of Computer Science

Toggle sidebar
bg1
Machine Learning (CS 5350/CS 6350) Due 29 Mar 2007
HW5: Bayesian inference
Note: Please submit the written aspects of assignments in postscript or PDF format only. I highly recom-
mend you use L
A
T
EX to prepare the assignments. A solution will be posted here after the due date. See
http://www.cs.utah.edu/classes/cs5350/handin.html for handin instructions.
1 PRML Exercises
None!
2 Written Exercises
1. Why does Bayesian inference not suffer from the need for regularization?
2. Gibbs sampling can be seen as a particular case of a Metropolis-Hastings algorithm with an appropriate
choice of proposal distribution. This proposal distribution, for instance, ensures that the acceptance
probability is always 1. Sketch a construction.
3 Programming
In the programming aspect of this assignment, we will revisit a Gaussian mixture model, but this time from
a Bayesian perspective.
Suppose we have the following model. We have two Gaussians with unknown means µ1and µ1. Both have
variance 1 (this if fixed). We put a Gaussian prior on these means with a common mean 0 and variance 1.
Also for simplicity, we’ll assume that each cluster is apriori equally likely (i.e., π= 0.5). That is, we have:
p(x1:N) = Zdµ0Zdµ1Nor(µ0|0,1)Nor(µ1|0,1) Y
nX
zn∈{0,1}
1
2Nor(xn|µzn,1)
The data is provided in hw5.m in the variable X. There are 20 data points in two dimensions.
In order to do the sampling, you first need to implement the log probability(X, mu1, mu2, z) function.
This should compute the value log p(X1:N, µ0, µ1, z); essentially the value in the above excluding the integrals
and sum. This is to compute the pfunction.
Next, we will implement an importance sampler and a Metropolis-Hastings sampler.
For the importance sampler, you should use the following proposal distributions:
q(µ0) = Nor(µ0|0,1)
q(µ1) = Nor(µq|0,1)
q(zn) = Bin(0.5)
That is, draw the µs from the prior mean, and draw each zfrom a fair coin flip.
1
pf2

Partial preview of the text

Download Bayesian Inference - Machine Learning - Homework 5 | CS 5350 and more Assignments Computer Science in PDF only on Docsity!

Machine Learning (CS 5350/CS 6350) Due 29 Mar 2007

HW5: Bayesian inference

Note: Please submit the written aspects of assignments in postscript or PDF format only. I highly recom- mend you use LATEX to prepare the assignments. A solution will be posted here after the due date. See http://www.cs.utah.edu/classes/cs5350/handin.html for handin instructions.

1 PRML Exercises

None!

2 Written Exercises

  1. Why does Bayesian inference not suffer from the need for regularization?
  2. Gibbs sampling can be seen as a particular case of a Metropolis-Hastings algorithm with an appropriate choice of proposal distribution. This proposal distribution, for instance, ensures that the acceptance probability is always 1. Sketch a construction.

3 Programming

In the programming aspect of this assignment, we will revisit a Gaussian mixture model, but this time from a Bayesian perspective.

Suppose we have the following model. We have two Gaussians with unknown means μ 1 and μ 1. Both have variance 1 (this if fixed). We put a Gaussian prior on these means with a common mean 0 and variance 1. Also for simplicity, we’ll assume that each cluster is apriori equally likely (i.e., π = 0.5). That is, we have:

p(x1:N ) =

dμ 0

dμ 1 Nor(μ 0 | 0 , 1)Nor(μ 1 | 0 , 1)

n

zn∈{ 0 , 1 }

Nor(xn | μzn , 1)

The data is provided in hw5.m in the variable X. There are 20 data points in two dimensions.

In order to do the sampling, you first need to implement the log probability(X, mu1, mu2, z) function. This should compute the value log p(X1:N , μ 0 , μ 1 , z); essentially the value in the above excluding the integrals and sum. This is to compute the p function.

Next, we will implement an importance sampler and a Metropolis-Hastings sampler.

For the importance sampler, you should use the following proposal distributions:

q(μ 0 ) = Nor(μ 0 | 0 , 1) q(μ 1 ) = Nor(μq | 0 , 1) q(zn) = Bin(0.5)

That is, draw the μs from the prior mean, and draw each z from a fair coin flip.

Machine Learning (CS 5350/CS 6350) 2

Initialize the sampler by drawing values directly according to the proposal distribution. Run the sampler for 1000 iterations. Plot a trace of the means over the 1000 iterations. Do they seem to converge to reasonable values? How long does this take? Repeat this process five times. Hand in graphs for the “best” trace and analyze the trends.

Next, for the MH sampler, we will use the following proposal distributions:

q(μ 0 ) = Nor(μ 0 | μ 0 , 1) q(μ 1 ) = Nor(μ 1 | μ 1 , 1) q(zn) = Bin((1 + zn)/3)

Repeat the same process as for the importance sampler (still initializing with the importance sampler’s proposal distributions). Turn in the same.