Showing posts with label conjugate prior. Show all posts
Showing posts with label conjugate prior. Show all posts

Friday, September 11, 2009

Gibbs sampling for DP Mixtures: technical details

My previous post Gibbs sampling procedure for GMM describes a Gibbs sampling procedure, which is adopted in Rasmussen's paper. In this approach, all the cluster parameters and the indicator variables are to be sampled i.e.,.

In the course "Dirichlet Processes: Tutorial and Practical Course" by Yee Whye Teh, Machine Learning Summer School 2007, Teh mentioned a collapsed Gibbs sampling scheme for the DP mixture model (DPMM). The collapse Gibbs sampling is much simpler in the sense that we only need to sample the indicator variables by integrating out the cluster parameters. It seems that my intuition is consistent to someone else. For example, in Hal Daume III's blog "collapsed Gibbs", he says "if you can collapse out a variable, you should". But he raised some concerns about why we need to sometimes to add auxiliary variables. However, in the case of mixture models, or topic models, the addition of auxiliary variable such as the indicator variable make lots of sense because it turns out it is much easier to sample these indicator variables than the cluster parameter variables. A more important reason to use indicator variable is reveal in the collapsed Gibbs sampling with Chinese restaurant process: we can integrate out the cluster parameters and only sample the indicator variables in each iteration.

Rarely I can found a real example about these algorithms in literature, except that in Ranganathan's thesis appendix, The Dirichlet Process Mixture (DPM) Model , gives an example of a simple case where the observations follows a univariate normal distribution with unknown mean but known, constant variance equal to unity.

Nevertheless, none of the three materials provide an overview of the Gibbs sampling techniques for DPMM. I search the literature and found Neal's review paper is very helpful: Markov Chain Sampling Methods for Dirichlet Process Mixture Models. In Neal's paper, three sampling schemes are described for the case when conjugate priors are used, namely:

  1. Gibbs sampling with Blackwell-MacQueen urn scheme
  2. Gibbs sampling with Chinese restaurant process
  3. Collapsed Gibbs sampling with Chinese restaurant process (also called as Rao-Blackwellized Gibbs sampling)
The method mentioned in Yeh's course is the third type. The method used in Rasmussen's paper is the second one.  Ranganathan adopts the Gibbs sampling with Blackwell-MacQueen urn scheme.

I also found the Sudderth has a good review about the two Gibbs sampling methods with Chinese restaurant process, in page 87-94, Chapter 2 of Sudderth's thesis 2006.

Combining the materials mentioned above , now I can have a good idea about the Gibbs sampling techniques for DPMM, at lease for the case when conjugate priors are used, which is my current interests. Eventually, I wrote up a technical note about the Gibbs sampling techniques when conjugate prior is used. It also includes a brief introduction of Dirichlet process and Dirichlet process mixture model. 

The report is here. 


Later on, I found several papers, which are perhaps the original papers about the algorithms described here:

On Xinyi Xu's course webpage, I found the following paper may be the original work about these algorithms:
    MacEarchern, S. (1998). Computational Methods for Mixture of Dirichlet Process Models. In Dey, Dipak D., Muller, Peter, and Sinha, Debajyoti (Eds.) Practical Nonparametric and Semiparametric Bayesian Statistics, 23-44. New York: Springer.
This paper also gives an example of beta-binomial distribution, which is very helpful.

"Bayesian Density Estimation and Inference Using Mixtures" (1995) by Michael D. Escobar and Mike West and "Computational Methods for Mixture of Dirichlet Process Models" by Steven N. MacEarchern are also original papers describing Gibbs sampling methods.

But I have no time to read these papers in details in recent days.

Friday, September 4, 2009

Derivation of Gibbs Sampling for Finite Gaussian Mixture Model

Recently, I read Rasmussen's NIPS 2000 paper "Infinite Gaussian Mixture Model". I found there is no much details how to derive the equations in the GMM model. In the process deriving these equations by myself, I found some problems in this paper. His definition of Gamma distribution introduces lots of confusions and his computation of Gamma posterior is doubtful. All these problems make it difficult for others to implement his algorithm in Matlab. So I decide to write down my derivation, together with the equations related to Gamma distribution, which are correct in my opinion. I also derive several standard conjugate distributions, including Gaussian and Gamma , as listed in the Table of conjugate distributions on wikipedia, which are used in my derivation.

I will try to do the Matlab coding later on. 



The PDF file of the report is here.

Saturday, August 29, 2009

Conjugacies in Bernulli distribution and its multivariate case

I am reading
Parameter estimation for text analysis
by Gregor Heinrich and
Distributed Gibbs Sampling of Latent Topic Models: The Gritty Details

by Yi Wang now, hoping to grasp the technical details of Gibbs sampling in LDA model. Both are excellent materials for newbies. Gregor's report provide more background knowledge such as Bayesian learning, Bayes network and related distributions. The derivation of Gibbs sampling for LDA only contains the second half of this report. Yi's report expands the derivations of the latter part. So it is better to read Gregor's report before Yi's. I do not know this point and start with Yi's and found it will be easier otherwise.

The following is a summary of the conjugacy of the Bernulli distribution and its multivariate counter part, summarized from Gregor's report.



bi-variate
multi-variate
single trial


multiple trials, n times

conjugate prior to p


conjugate prior's normalization term


posterior of given n observations


likelihood of n observations in terms of hyprparameter, by integrating out parameter p







Friday, August 28, 2009

confusion of conjugate prior

I was confused by the conjugate prior:
  • Beta distribution is the conjugate prior of Bernulli distribution; and Beta distribution is also the conjugate prior of binomial distribution;
  • Dirichlet distribution is the conjugate prior of multivariate Bernulli distribution; and Dirichlet distribution is also the conjugate prior of multinomial distribution;
Why could a distribution (Beta, Dirichlet) could be conjugate prior for two distributions?
After reading the chapter 2 and Appendix B in Bishop's PRML book again and again, I finally realized one thing today: conjugacy is related to the parameter rather than the distribution and this explains the above puzzles.

See the definition of conjugate prior on wikipedia:

In Bayesian probability theory, a class of prior probability distributions p(θ) is said to be conjugate to a class of likelihood functions p(x|θ) if the resulting posterior distributions p(θ|x) are in the same family as p(θ); the prior and posterior are then called conjugate distributions, and the prior is called a conjugate prior for the likelihood.

Thus,
  • Beta(μ|a,b) is the conjugate prior of Bernulli(x|μ) and binomial(m|N,μ) , because in both distributions, μ has a conjugate prior Beta
  • Dirichlet distribution is the conjugate prior of multivariate Bernulli Discrete(x_{1:K}|μ) and multinomial(m_{1:K}|μ), because in both distributions, vector μ has a conjugate prior Dirichlet
It worth to note that the Posterior hyperparameters listed in the conjugate pairs on wikipedia are computed for the case of n observation, while in some reference, they are computed for the case of one observation.
For example, for Bernulli(x|p), its conjugate prior is Beta(p|a,b), then the posterior distribution of the parameter p after giving n observations is
p(p|x_{1:N}, a, b) = Beta(p|a+n_1, b+n_0), where n_1 and n_0 are the counts of x_i = 1 and x_i = 0 respectively.

But for the example in this website, the poster distribution is for the case of one observation.