Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
help on lda (latent dirichlet allocation) code

Subject: help on lda (latent dirichlet allocation) code

From: Xuefei Cao

Date: 13 Oct, 2011 02:05:29

Message: 1 of 1

I saw a LDA code which is very efficient, but I don't understand the code.
The code is as follows:
Initialize all the parameters
 for iter = 1:ITER
       PZ =dirichlet_sample(histc(ZWD,1:K)' +Gamma);
               for k = 1:K
                    PWZ = dirichlet_sample(histc(WordInx(ZWD==k),1:P)' + Beta);
                    PDZ = dirichlet_sample(histc(DocInx(ZWD==k),1:N)' + Alpha);
                    PZWD(k,:) = log(PWZ(WordInx)) + log(PDZ(DocInx)) + log(PZ(k));
       PZWD = exp(PZWD - repmat(max(PZWD), K, 1)) + realmin;
       PZWD = PZWD./(repmat(sum(PZWD,1),K,1));
       ZWD = randmult(PZWD)';

The basic idea:p(z|d,w) propto p(w|z)*p(d|z)*p(z).

I don't understand:
1) What does PZ mean?
2) What is Gamma?
3) What does ZWD mean?
4) What does PZWD mean?
5) Is this the gibbs sampling of LDA? If not, what is it?

Could someone understand the code and help me out? Thanks a lot!

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us