Skip to content

Instantly share code, notes, and snippets.

@alextp
Created August 22, 2010 20:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alextp/544248 to your computer and use it in GitHub Desktop.
Save alextp/544248 to your computer and use it in GitHub Desktop.
def collapsed_likelihood(tprior, gmean, gvar, tcount):
p0 = sum(np.log(gamma_pdf(tp, gmean, gvar)) for tp in tprior)
p0 += tcount.shape[0]*(gammaln(sum(tprior))-sum(gammaln(tp) for tp in tprior))
for d in xrange(tcount.shape[0]):
for i,t in enumerate(tcount[d]):
p0 += gammaln(t + tprior[i])
p0 -= gammaln(sum(tcount[d]) + sum(tprior))
return p0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment