Skip to content

Instantly share code, notes, and snippets.

@Dr-Eti
Dr-Eti / pLSA.R
Last active May 2, 2021 09:52 — forked from ratsgo/pLSA.R
pLSA
# Modifies the code in
# github thread: https://gist.github.com/ratsgo/c25deb6d79f3ab8b0b050af751fbbdb8#file-plsa-r-L78
# to speed it up by introducing vectorisation alternatives to nested for loops
# and by avoiding cumbersome string lookups
# assuming this is based on Hofmann (2001) https://doi.org/10.1023/A:1007617005950, p. 182 eqns 6, 11 and 12 but re-casted for parametrization as in eq. 5
# prepare corpus
corpus <- matrix(c(1,2,0,0,0,0,