I'm looking for a simple and easy to read introduction to using MCMC with a dirichlet process prior. Or perhaps using MCMC in any machine learning scenario, eg Gaussian Process.

I've been circling around various papers and tutorials (Neal, Teh, Sahu, Ghahramani, Ferguson, Escobar and West, ... ), but I can't find anything that explains in straightforward procedural terms, specifying explicitly each equation I would need to implement MCMC for DP or GP.

Edit: I got this far: my mcmc dp progress

  • $\begingroup$ Gaussian Processes for Machine Learning (2006) by Rasmussen & Williams (pdf) has a lot of information (theory, simulations, etc). $\endgroup$ – Zen Mar 8 '14 at 0:52

Its not a paper, but I found some Matlab code that implements a DP prior for an infinite Gaussian mixture model. The code uses Gibbs sampling to infer a GMM (and the number of components in the mixture) over some input data. The code is pretty readable and it has helped me quite a bit to see the DP in action in a concrete example.

| cite | improve this answer | |
  • $\begingroup$ This is very useful to me. The function 'collapsed_gibbs_sampler.m' can be run with very simple arguments, and then compared with algorithm 3 in Neal's 1998 paper. Thanks! $\endgroup$ – Hugh Perkins Apr 2 '12 at 17:47

MCMC sampling for DPMM is quite challenging and that's for many reasons, the main one being that the model is infinite and the distribution is not that easy to work with. Employing algorithms such as metropolis is non-trivial since there are actually quite a few degrees of freedom in how you specify your proposal distributions and acceptance ratios.

You can trace part of the evolution of DPMM MCMC algorithms in the work of Radford Neal (University of Toronto) here.

You could start with this 1998 paper and move on to his split and merge for conjugate and non-conjugate models from 2000 and 2005. These will help you understand the main ideas behind MCMC sampling for DPMMs.

When you feel brave you can hop on to the most recent advances. One of them is Chang's and Fisher's (MIT) 2013 paper which you can find here. You can also find code and a demo on Jason Chang's website.

If you need a more general mathematical exploration of DPs you can find many of them online. A good one is by Yee Whye Teh (UCL). I would post more links but my reps are not enough at this point :-)

| cite | improve this answer | |

I have the same feeling. This is as closest as I've come:


The algorithm explained starting at page 37 is understandable, however I still wish to see a very simple example written out step by step so I'm more confident of which each term means.

I attempted to implement the algorithm in R, below is my code, not efficient and not sure if it is all correct!

#Dirichlet mixture of normals
#flat prior on mu - posterior normal
#flat prior on precision - posterior gamma

###generate data

###get probs for each component

  for(j in 1:length(cProb))


###get probs for new component

  #predictive distribution is t




  for(i in 1:n){

    ####if c_i singleton remove

    ####draw new c_i
    #get probabilities for components


    ####if new c_i draw new eta
      #var: posterior is inverse gamma

      #mean: posterior is normal

  } #end loop over observations

  #updata etas
  for(i in 1:length(unique(c))){
  } #end update etas

  if(idx==nsim) break
} #end repeat

###plot results
for(i in 1:length(probs))

for(i in 1:length(grid))

| cite | improve this answer | |
  • 1
    $\begingroup$ omg! a paper which actually writes down the likelihood function for the observed data! $\endgroup$ – probabilityislogic Oct 19 '13 at 7:19

My belief is that there can hardly be such a paper, because the concepts and implementation details are not straighforward. Hence, even the best papers will be somewhat involved and you need to go through that.

| cite | improve this answer | |

(Edited) Since, no one had added this. Let me contribute here.

Sethuraman's stick breaking representation for Dirichlet Process is incredibly useful for understanding DP model and also for simulating DP. Basically, Sethuraman tells us that one can think of the weights which appear in Dirichlet Process as a product of stick breaking process (beta). Here's the link for the paper. http://www.jstor.org/stable/24305538?seq=1#page_scan_tab_contents

One of the main reason, why DP is hard to handle because it's literally an infinite mixture model. An excellent paper by Ishwaran tells us that it's alright to approximate DP as a finite mixture model. Here's the paper https://people.eecs.berkeley.edu/~jordan/sail/readings/archive/ishwaran-Mixture.pdf.

Once, you have internalized above methods, it's fairly straightforward to do Gibbs Sampling with DP with say Normal Base Distribution. Let's say that your data y also comes from the Normal Distribution. let's also that the cluster mean of your data (y) comes from DP. Then, here are the steps to do a simple Gibbs Sampling with DP

  1. Choose a large K (total number of cluster).
  2. Initialize cluster mean and variance for each cluster.
  3. Initialize the stick breaking prior. 2#. Choose a data point
  4. Compute the probability that data point lies in a particular cluster .
  5. Do the Step 3 for all of the cluster.
  6. Normalize the above probability, so that it adds up to 1.
  7. Using the above probability allocate the data point to a particular cluster.
  8. Do step 3-6 for all your data points.
  9. Now update the number of points in all the cluster.
  10. Using basic Bayesian Methods, update the cluster means and cluster variance.
  11. Repeat the above process for however number of iteration you want.
  12. Discard the firs half of your sample.
  13. Viola, you did a MCMC for your DP model.

Here's an excellent R code shared by Brian Neelon, which uses the above two concept to make an elegant DP code. http://people.musc.edu/~brn200/r/DP03.r

| cite | improve this answer | |
  • $\begingroup$ I forgot to add the link for Sethuraman's paper. Here it is jstor.org/stable/24305538?seq=1#page_scan_tab_contents $\endgroup$ – user3373954 Jul 20 '17 at 21:05
  • $\begingroup$ That would describe DPs, but not MCMC with DPs, which is a significantly more challenging problem :-) $\endgroup$ – Hugh Perkins Jul 21 '17 at 12:22
  • $\begingroup$ Well, the above code I shared is implementing a Gibbs Sampler for DP, which is technically MCMC with DP. The point that I am making that is if you follow Sethuraman's construction and finite approximation of Ishwaran then implementing a Gibbs Sampler for DP model isn't that tough, but you need to get your hands dirty. I am in no way undermining Radford Neal's work in MCMC for DP, but I don't think that's a good jumping point for beginners. $\endgroup$ – user3373954 Jul 21 '17 at 15:33
  • $\begingroup$ @user3383954 Ah, fair enough. Not obvious from your text though. And links are not really considered answers. Perhaps you could consider clarifying this in your answer? $\endgroup$ – Hugh Perkins Jul 22 '17 at 0:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.