I'm trying to wrap my head around Topic Modeling based on LDA with Gibbs sampling (Griffiths, Steyvers 2004: Finding Scientific Topics). What struck me when reading some Python implementations like this one or that one, was that it appears that the actual word counts in the input matrix (the document-term-matrix – DTM) are never used in the calculations. When iterating over the words in a document, it is done so by iterating over the non-zero occurrences of words in the vocabulary (for w in word_indices(matrix[m, :]): ...
– m denotes a document index) but the actual word count is not used in the calculations for the probability distribution p_z
(prob. across topics given a word in a document).
So it appears to me, that for the algorithm it is only important if a word exists in a document and not how often it occurs there. If this was the case, then with a binary DTM that only denotes if a certain word occurs in a document or not, we would achieve similar results as with a conventional DTM containing the number of word occurrences. However, this is not (or should not be) the case and this confuses me. Can someone clarify this? Did I miss something or are the referenced implementations wrong? How and where do the actual word counts in a DTM influence the results?